Java 'seven segment display' and problems, can anyone help me

import java.awt.*;
import java.applet.*;
import javax.swing.*;
import javax.swing.JButton.*;
import javax.swing.JFrame.*;
public class test extends Applet{
     Font bigFont;
     Color redColor;
     Color bgColor;
     Button clickOnMe;
     Button clickOnMe2;
     int value = 0000;
     int value2 = 0000;
     int segmentArray[][] = {{0,0,1,0,0,1,0},{1,0,1,1,1,0,1},{1,0,1,1,0,1,1},{0,1,1,1,0,1,0},{1,1,0,1,0,1,1},{1,1,0,1,1,1,1},{1,0,1,0,0,1,0},{1,1,1,1,1,1,1},{1,1,1,1,0,1,0},{1,1,1,0,1,1,1}};
     int optiontest = 0;
     public void init(){}
     if (optiontest == 1)
     clickOnMe = new Button("Diesel");
     add ("left",clickOnMe);
     clickOnMe2 = new Button("Petrol");
add ("centre",clickOnMe2);
     bigFont= new Font("Arial",Font.BOLD,16);
     bgColor=Color.white;
     setBackground(bgColor);
     } public void init stop()
public boolean action (Event e, Object args)
{ if (e.target == clickOnMe)
               optiontest ++;
if (e.target == clickOnMe2)
          value2 ++;
repaint();
return true;
     public void paint (Graphics g)
          g.setColor(Color.black);
          g.drawString("Cost" + value, 275, 170);
g.drawString("Cost" + value2, 275, 200);
          g.setColor(Color.red);
          g.drawRect(300, 300, 150, 150);
          g.drawRect(270, 150, 210, 200);
          g.drawRect(270, 270, 210, 150);
          g.drawRect(270, 270, 450, 270);
     g.fillRect(270, 270, 210, 270);
          g.drawRect(480, 320, 240, 220);
          g.setColor(Color.black);
public boolean stop()
          if (optiontest < 10){
          // seg 1
               if (segmentArray[optiontest ][0] == 1){
                    g.drawRect(100, 100, 50, 0);
          // seg 2
               if (segmentArray[optiontest ][1] == 1){
                    g.drawRect(100, 100, 0, 50);
          // seg 3
               if (segmentArray[optiontest ][2] == 1){
                    g.drawRect(150, 100, 0, 50);
          // seg 4
               if (segmentArray[optiontest ][3] == 1){
                    g.drawRect(100, 150, 50, 0);
          // seg 5
               if (segmentArray[optiontest ][4] == 1){
                    g.drawRect(100, 150, 0, 50);
          // seg 6
               if (segmentArray[optiontest ][5] == 1){
                    g.drawRect(150, 150, 0, 50);
          // seg 7
               if (segmentArray[optiontest ][6] == 1){
                    g.drawRect(100, 200, 50, 0);
          // When the number is biggest than 10 and less than 100
          if (optiontest >10 && optiontest < 100)
               // Units \/
               // seg 1
               if (segmentArray[optiontest - 10][0] == 1){
                    g.drawRect(100, 100, 50, 0);
          // seg 2
               if (segmentArray[optiontest -10][1] == 1){
                    g.drawRect(100, 100, 0, 50);
          // seg 3
               if (segmentArray[optiontest -10][2] == 1){
                    g.drawRect(150, 100, 0, 50);
          // seg 4
               if (segmentArray[optiontest -10][3] == 1){
                    g.drawRect(100, 150, 50, 0);
          // seg 5
               if (segmentArray[optiontest -10][4] == 1){
                    g.drawRect(100, 150, 0, 50);
          // seg 6
               if (segmentArray[optiontest -10][5] == 1){
                    g.drawRect(150, 150, 0, 50);
          // seg 7
               if (segmentArray[optiontest -10][6] == 1){
                    g.drawRect(100, 200, 50, 0);
               // The tens section \/
          // seg 1
               if (segmentArray[optiontest / 10][0] == 1){
                    g.drawRect(100 - 70, 100, 50, 0);
          // seg 2
               if (segmentArray[optiontest / 10][1] == 1){
                    g.drawRect(100 - 70, 100, 0, 50);
          // seg 3
               if (segmentArray[optiontest / 10][2] == 1){
                    g.drawRect(150 - 70, 100, 0, 50);
          // seg 4
               if (segmentArray[optiontest / 10][3] == 1){
                    g.drawRect(100 - 70, 150, 50, 0);
          // seg 5
               if (segmentArray[optiontest / 10][4] == 1){
                    g.drawRect(100 - 70, 150, 0, 50);
          // seg 6
               if (segmentArray[optiontest /10][5] == 1){
                    g.drawRect(150 - 70, 150, 0, 50);
          // seg 7
               if (segmentArray[optiontest /10][6] == 1){
                    g.drawRect(100 - 70, 200, 50, 0);
}

Please use the CODE tags when you post your code. It makes it much more readable. Based upon your Subject, I can't understand your problem. Please be more specific and explain your difficulty in your message.

Similar Messages

  • Gmail on iphone was working fine until yesterday when it prompted me with the message cannot get mail user name or password for gmail is incorrect, i have tried deleting the account and re-created a new account, same problem, can anyone help?

    gmail on iphone was working fine until yesterday when it prompted me with the message "cannot get mail user name or password for gmail is incorrect", i have tried deleting the account and re-created a new account, same problem, can anyone help?

    paulcb, you're a genius, it worked, thank you so much, you don't know how much stress you have taken off my shoulders, I am constantly on my email in my iphone everyday.  Thanks a million, take care. Robert.

  • I bought a new Epson printer WR-7620 on Saturday and the Air Printer is not working. I spoke to Epson and they said it is an Apple problem, can anyone help. Thanks Peter

    I bought a new Epson printer WR-7620 on Saturday and the Air Printer is not working. I spoke to Epson and they said it is an Apple problem, can anyone help. Thanks Peter

    Peter,
    deggie gave you that link so you'd know that airprint is a reduced-options print system, designed for mobile devices (not Macs), and you need to use the specific airprint driver on the Mac when adding the printer if you want Airprint, no-options printing. Otherwise, select the "non-airprint" driver when you add the printer.
    It may be helpful to Reset the Printing System to get OS X to find the right driver.
    Mac OS X: How to reset the printing system - Apple Support
    (And "not working" doesn't help us to help you - please give more detail next time)

  • How do I change DNS to Business Catalyst servers.  I am having problems can anyone help please?

    How do I change DNS to Business Catalyst servers.  I am having problems can anyone help please?

    What problem are you having?
    Have you read this KB? - Domain name and DNS: Quick reference

  • HT3633 I have an error message that reads: java.lang.noclassdefFounder - need to fix can anyone help?

    I have an error message that reads: java.lang.noclassdefFounder - need to fix can anyone help?

    That's a bug in whatever Java program you're running.
    That's not an error specific to OS X.
    (There's usually a whole lot more text dumped by Java, too.)
    Check with whoever wrote or is supporting the package you're working with.

  • My ipod shuffle 4th gen bought today and the voice over works for naming playlist and battery percent but wont name song and artist can anyone help also is the voice over button meant to be soft when pushed ?

    my ipod shuffle 4th gen bought today and the voice over works for naming playlist and battery percent but wont name song and artist can anyone help also is the voice over button meant to be soft when pushed ?
    thanks

    This document explains setting up and using VoiceOver.
    http://support.apple.com/kb/ht4322
    The overall settings for VoiceOver is on the shuffle's Summary screen in iTunes.
    Artist name and song name - Press and release the VoiceOver button. 
    The playlist menu - Press and hold the VoiceOver button.

  • Touch screen on my iphone 4 is frozen and unresponsive can anyone help me. i`ve tried turning it off and on but no change at all

    touch screen on my iphone 4 is frozen and unresponsive can anyone help me. i`ve tried turning it off and on but no change at all

    Basics from the manual are restart, reset, restore.
    Try all of these.
    iPhone User Guide (For iOS 4.2 and 4.3 Software)

  • HT1212 I forgot my passcode and i have no backup of my Ipad, it is locked and disabled, can anyone help to restore factory settings atleast as a new ipad

    I forgot my passcode and i have no backup of my Ipad, it is locked and disabled, can anyone help to restore factory settings atleast as a new ipad

    Hey salosawaya,
    If you have never synced your device with iTunes and you forgot your passcode, you'll follow these directions:
    If you see one of following alerts, you need to erase the device:
    "iTunes could not connect to the [device] because it is locked with a passcode. You must enter your passcode on the [device] before it can be used with iTunes."
    "You haven't chosen to have [device] trust this computer"
    If you have Find My iPhone enabled, you can use Remote Wipe to erase the contents of your device. If you have been using iCloud to back up, you may be able to restore the most recent backup to reset the passcode after the device has been erased.
    Alternatively, place the device in recovery mode and restore it to erase the device:
    Disconnect the USB cable from the device, but leave the other end of the cable connected to your computer's USB port.
    Turn off the device: Press and hold the Sleep/Wake button for a few seconds until the red slider appears, then slide the slider. Wait for the device to shut down.
    While pressing and holding the Home button, reconnect the USB cable to the device. The device should turn on.
    Continue holding the Home button until you see the Connect to iTunes screen.
    iTunes will alert you that it has detected a device in recovery mode. Click OK, and then restore the device.
    via: iOS: Forgotten passcode or device disabled after entering wrong passcode
    http://support.apple.com/kb/HT1212
    Welcome to Apple Support Communities!
    Regards,
    Delgadoh

  • I click buy Lion but it just spins and spins and spins, can anyone help?

    I am trying to upgrade my system OS but when I go to the appstore and click lion and click buy it just spins and spins and spins and spins, can anyone help?

    Lion is not available for download from the App Store.

  • Hi I have a geometry problem.Can anyone help with java code

    Hi I have a non simple polygon . My job is to make it a simple. for that First I need to find the intersecting lines say line AB intersects line CD. If so then I must replace AB & CD with AC & BD or AD or BC which ever keeps the polygon closed . So can anyone help me out with this code
    import java.io.*;
    import java.awt.*;
    import java.awt.geom.*;
    import java.awt.image.*;
    import javax.swing.*;
    public class Simple{
    static int POINTWID = 4; // size of points
    // the x and y arrays hold the coordinates
    // the B array is the order of the points in the polygon
    // You want to fill the C array with the simple polygon
    static double x[] = new double[200];
    static double y[] = new double[200];
    static int B[] = new int[200]; // the permutation matrix
    static int C[] = new int[200]; // the one that becomes simple
    static SimpleFrame myFrame;
    static int numPoints = 3;
    public static void main(String args[]) {
    makePolygons();
    // Create the frame to draw on
    myFrame = new SimpleFrame();
    myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    myFrame.setSize(600, 600);
    myFrame.setVisible(true);
    public static void makePolygons(){
    // Build an array of random points in the unit square
    for(int i = 0; i < numPoints; i++){
    x[i] = Math.random();
    y[i] = Math.random();// Sample program
    B[i] = i; // default permutation
    // Create the simple polygon
    createSimplePolygon();
    * This is the only function you need to mess with
    public static void createSimplePolygon(){
    // Initialize the C[] array with the identity permutation
    for(int i = 0; i < numPoints; i++)
    C[i] = i;
    // Bubble sort the points from left to right
    for(int i = 0; i < numPoints; i++)
    for(int j = 0; j < numPoints - 1; j++)
    if(x[C[j]] > x[C[j+1]]){
    int temp = C[j];
    C[j] = C[j+1];
    C[j+1] = temp;
    public static class SimpleFrame extends JFrame{
    public static JSlider numPointsSlider;
    public SimpleFrame()
    super("Create you own Simple Polygon");
    Container content = getContentPane();
    content.setLayout(new java.awt.BorderLayout());
    JTabbedPane tabbedPane = new JTabbedPane();
    tabbedPane.setPreferredSize (new java.awt.Dimension(300, 400));
    tabbedPane.addTab("Scrambled", new ScrambledPanel());
    tabbedPane.addTab("Simple", new SimplePanel());
    content.add(tabbedPane, java.awt.BorderLayout.CENTER);
    // Slider for the number of points
    numPointsSlider = new JSlider (javax.swing.SwingConstants.HORIZONTAL,
    3, 100, 11);
    numPointsSlider.addChangeListener (new javax.swing.event.ChangeListener () {
    public void stateChanged (javax.swing.event.ChangeEvent evt) {
    numPointsSliderStateChanged (evt);
    content.add(numPointsSlider, java.awt.BorderLayout.SOUTH);
    private void numPointsSliderStateChanged (javax.swing.event.ChangeEvent evt) {
    numPoints = numPointsSlider.getValue();
    makePolygons();
    repaint();
    public static class ScrambledPanel extends JPanel{           
    public void paintComponent(Graphics g){
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D) g;
    // First set the scaling to fit the window
    Dimension size = getSize();
    int Xwid = (int) (0.95 * size.width);
    int Ywid = (int) (0.95 * size.height);
    // First draw the segments
    g2.setColor(Color.red);
    for(int i = 0; i < numPoints; i++)
    g2.drawLine((int) (Xwid * x[B[i]]),
    (int) (Ywid * y[B[i]]),
    (int) (Xwid * x[B[(i+1) % numPoints]]),
    (int)(Ywid * y[B[(i+1) % numPoints]]));
    // Now draw the points
    for(int i = 0; i < numPoints; i++){
    g2.fillRect((int) (Xwid * x) - POINTWID,
    (int) (Ywid * y[i]) - POINTWID,
    2*POINTWID + 1, 2*POINTWID + 1);
    public static class SimplePanel extends JPanel{
    public void paintComponent(Graphics g){
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D) g;
    // First set the scaling to fit the window
    Dimension size = getSize();
    int Xwid = (int) (0.95 * size.width);
    int Ywid = (int) (0.95 * size.height);
    // First draw the segments
    g2.setColor(Color.red);
    for(int i = 0; i < numPoints; i++)
    g2.drawLine((int) (Xwid * x[C[i]]),
    (int) (Ywid * y[C[i]]),
    (int) (Xwid * x[C[(i+1) % numPoints]]),
    (int)(Ywid * y[C[(i+1) % numPoints]]));
    // Now draw the points
    for(int i = 0; i < numPoints; i++){
    g2.fillRect((int) (Xwid * x[i]) - POINTWID,
    (int) (Ywid * y[i]) - POINTWID,
    2*POINTWID + 1, 2*POINTWID + 1);

    Hi I am sorry I could explain you properly . Ok
    My program gives me a polygon(as you can see when u
    run this program)But the polygon is a non simple
    polygon.So to make this polygon we must remove all
    the crossings betweeen edges in the polygon.The
    algorithm which i gave will remove all the crossings
    and make the polygon simple.You did not give an algorithm!
    SO my job is to take the
    existing code and implement the algorithm for this
    program in the Createsimpelpolygon() function. For
    this First the program must find whether two edges
    cross if they cross then swap the vertices like
    replace AB & CD with AC & BD or AD & BC.Which ever
    keeps the polygon closed . Still not entirely clear to me. You cannot just go and replace vertexes from a polygon: that way you'll end up with a different polygon.
    So as we go on we find the
    many crossings and iterate the algorithm on all the
    crossings until we get simple polygon.Like I said: I don't really understand what it is you're after. You did not respond to my suggestions, so I gather it is not what you're after?
    What about Polygon Tessellation (Google for it)? Perhaps that's what you want.
    Also, why do you not create a (or use java.awt's) Point class and a Polygon class which holds a java.util.Set of Point's? Your current code looks rather messy.

  • Batch processing problems-can anyone help?

    Setup: Quadcore, 4GB RAM, 4 internal drives all with plenty of space, Leopard OS, latest version.
    Software: CS4 with Photoshop Extended; all updates installed. I also have CS3 installed; only use Bridge and PS in both apps.
    Problem: Working in CS4. All edits/crops/corrections done in the Camera Raw window; all edits saved and viewable in Bridge. However, when I use Batch from the Tools dropdown (Tools > Photoshop > Batch), and check all the usual places, select an Action, select a Destination, and hit "Go", the results are totally weird. Some images process as expected, but many are at least two stops overexposed.
    All individual files will Open, and can be Saved As manually; all works fine. That is in fact how my assistant and I got the job done tonight. The Batch Action is simplicity itself: Open, Save As (JPEG level 9), and Close file—but if I run Batch on the same files that can be opened and Saved As perfectly, it all goes crazy; three quarters of the files are totally overexposed, in blocks (10–25, roughly), and at random.
    I have used the Ctrl + Alt + Shift after opening Bridge; I have run Cocktail; and lit the right incense. But this still will not work properly! Can anyone help???

    Batching the same files in CS3 works perfectly, in terms of the processed JPEGs at least being correctly exposed, but the CS4-only edits (like the healing brush) are not recognised, nor are many, tho' not all, of the crops.
    I have decided to deactivate and uninstall, then reinstall CS4, after upgrading to Snow Leopard. Usually, I wait for a few months for others to report on OS update interactions with CS and FCP, but since CS4 as installed was useless and I had done the usual resets of Preferences without any change to Batch Processing's reliability, I felt I could not be worse off.
    So, after upgrading to Snow Leopard, I will reinstall CS4 (and all apps this time, rather than just PS and Bridge, as I usually do) in case there are soime weird unintended consequences of a Custom install.
    Very frustrating and time-consuming, and I wonder what I might have done to create this problem—seeing as no one commented, I can only assume that this is an unique experience.
    I will report back today, hopefully.

  • Saving Problem, can anyone help me?

    To All,
    I am having a severe problem with saving my GUI.
    Due to the fact i have internal frames, i am using JDesktopPane, and i am trying to save the whole desktop, so that when i load it, i can add this desktop to the GUI again.
    I do this action from the menu "save" and "open" option, but when i do it, there are a lot of exceptions, and does not work.
    Am i doing this the right way? If not can anyone help me?
    Thank You.

    There are a lot of issues with saving off Swing stuff. Note all of the notes about swing serialization only be suitable for short term uses. Its hard to tell from your post, but it sounds like you might be trying to serialize it. The thing to do is to mark all of your swing stuff as tranient, and/or make it externalizable. Then, you save any important data and reset it when you readExternal (things like window position and so on) its a pain , but it should work and you will have more assurance that things saved will work in later releases. You can try different vairations of this, but I suspect the major errors have to do with you trying to save off iomages and so on. Really better to rebuild this stuff then try to unserailize it. More effecient too!

  • Major problem -  Can anyone help?

    Hi,
    A couple of months ago I was downloading the OS update and my computer was turned off (at the plug) by mistake. Since then I can't load up properly in my own user (although other users can access theirs OK).
    All I get is that the wallpaper loads on the desktop and I get a spotlight icon in the top right of the screen and the cursor wheel just spins - and that's it.
    I can't use it or access my files. Can anyone help by telling me how I can:
    a, fix the problem of loading up or
    b, access my files from another user when they don't have priveleges.
    Any help is appreciated as I have some important files I need to get hold of and can't.
    Mac Mini   Mac OS X (10.4.7)  

    Hi,
    A couple of months ago I was downloading the OS
    update and my computer was turned off (at the plug)
    by mistake. Since then I can't load up properly in my
    own user (although other users can access theirs
    OK).
    All I get is that the wallpaper loads on the desktop
    and I get a spotlight icon in the top right of the
    screen and the cursor wheel just spins - and that's
    it.
    I can't use it or access my files. Can anyone help by
    telling me how I can:
    a, fix the problem of loading up or
    b, access my files from another user when they don't
    have priveleges.
    Any help is appreciated as I have some important
    files I need to get hold of and can't.
    Mac Mini Mac OS X (10.4.7)
    Login as a different user, then find the folder on the hard drive where your files are, select this folder in the Finder window and "Get Info" on it from the "File" menu. In the Get Info window go down where it says "Ownership & Permissions" and select the "Details". Change the owner of that folder to the name of the user that you are logged in as. You may need to enter the administrator password to authenticate, this will give you full control (read/write) access to the files inside the folder as admin. Repeat these steps for each folder that has items you want to retrieve. After you retrieve the files you want, you should just do a re-install of the Operating system from the install disk. The system is most likely corrupt and beyond repair since the update was halted by a power failure.
    Good Luck!

  • Jukebox Zen Xtra problems - can anyone help

    Hi
    I have a 30G Xtra Jukebox. Of the original memory I have about 7.5 G free. Problem is I cannot seem to use it. Everytime I transfer from media source the track number goes up but the memory counter stays the same. When I unplug the track are simply not there.
    I have reformatted and reloaded, all fine until I want to add extra then the same problem. I have updated the firmware, cleaned the disk. All to no avail. Is there a maximum number of tracks that I can have, I thought that as long as I have memory I can keep recording?
    Can anyone help. thanks.........................

    The limit is around 6,000 tracks, but varies with the amount of tag data. Lots of tag data and it will be less.

  • Connecion problems, can anyone help?

    Hello,
    Ive recently brought an 8900 from ebay, im with orange in the uk and have the blackberry addon data usage thingy. I've been usign it for a while now, and the connections seems really really slow. So kinda guessed, well GPRS sucks. But I've recently went into the browser settings, and switched from the default Internet to Orange World (wap) and this is like a zillion times faster. On the default it can take up to 2-3minutes for the browser to get off requesting and start loading the page, even on just google, yet on the orange world zip it loads in seconds. Whats the difference here? All my apps run slowly, presuming with the default settings, is there anyway to get these speeds up to that of the wap setting?
    Can't understand why the default internet settings suck so badly. Have just updated all my software, done a reboot from scratch, redownloaded my service books and nothing its still the same. Can anyone help?
    Many thanks,
    Mike

    Have you tried restart your computer and unplug your iPhone from the cable? I sometimes have this problems and I was told to unplug and re-plug the iPhone.
    Hope it helps.

Maybe you are looking for

  • -Match and $Matches[0] in a single if?

    This bit of code seems to be working intermittently for me, and I can't nail down what the problem is. if (($Places[-1] -match "([0-9])") -and ([bool]($Matches[0] -as [int]))) { some stuff If I make it two different if's it always works, but for the

  • Significance of Administrators Tab & Object Permissions Tab in OIM PF

    Hi, Can any one explain me the significance of Administrators Tab & Object Permissions Tab in OIM Process Form? Are they same? if I have added a group in Administrators Tab and not in Object Permissions Tab , what will be the impact of this in terms

  • After effects cs4 problem.

    Hi guys. So I got the new version of After Effects. Everything works fine till today. Whatever composition I make it says After Effects error: AE_OpenGL: A texture in this composition is too small to render I don't get it my clips are often in HD qua

  • Help please: wwv_flow_custom_auth_sso.process_success does not seem to be w

    (I am trying to get all my apex applications to use the Global SSO... but initially I am trying with my own SSO instance to make sure I am ready...) (My APEX listens on 8080 in burl1-demo12.us.oracle.com ... my SSO is in burl1-demo14.us.oracle.com I

  • Creating XSD from Castor created classes

    I am trying to create the original XSD files from java classes created by Castor 0.4.3. Is there a way to do this without having to dig into the classes themselves? Thanks for your help, Scott