Using a button several times?

Hello, I am wanting to know how to go about using a button more than once. Like press once and get the first part of code, press again and get a second part of the code, and so on. If I increment the variable count it will automatically go to the next part of the code. How can I stop that until the button is pressed again.?
public void  actionPerformed(ActionEvent e)
          if(answer3Int == 1 && answer2Int == 0 && answer1Int == 0)
               score = 5;
          else if(answer3Int == 1 && answer2Int == 1 && answer1Int == 0 || answer3Int == 1 && answer2Int == 0 && answer1Int == 1)
               score = 2;
          else if(answer3Int == 1 && answer2Int == 1 && answer1Int == 1)
               score = 1;
          totalScore = (totalScore + score);
          System.out.println(totalScore);
          ++count;
          

I am looking at your suggestions but I am still lost on how I could accomplish this:
Here is my code so far. I hope it is easier to read:
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class HedgeYourBetUsingFile extends JFrame implements ActionListener, ItemListener
     FlowLayout flow = new FlowLayout();
     JLabel label = new JLabel("Choose the state that best answers the question.");
     JTextField question = new JTextField(35);
     JCheckBox answer1 = new JCheckBox("California", false);
     JCheckBox answer2 = new JCheckBox("New York", false);
     JCheckBox answer3 = new JCheckBox("Illinois", false);
     JButton button = new JButton("Submit answer");
     String output, insChosen;
     JPanel panel = new JPanel();
     Container con;
     String questionString = "";
     int answer1Int = 0;
     int answer2Int = 0;
     int answer3Int = 0;
     int count = 0;
     int score = 0;
     int totalScore = 0;
     public HedgeYourBetUsingFile()
          super("CheckBox Demonstation");
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          con = getContentPane();
          con.add(panel);
          panel.setLayout(flow);
          label.setFont(new Font("Arial", Font.ITALIC, 15));
          answer1.addItemListener(this);
          answer2.addItemListener(this);
          answer3.addItemListener(this);
          panel.add(label);
          panel.add(question);
          panel.add(answer1);
          panel.add(answer2);
          panel.add(answer3);
          panel.add(button);
          button.addActionListener(this);
          questionString = ("What state had the first Aquarium?");
          question.setText(questionString);
     public static void main(String[] arguments)
          final int FRAME_WIDTH = 400;
          final int FRAME_HEIGHT = 220;
          HedgeYourBetUsingFile frame =
               new HedgeYourBetUsingFile();
          frame.setSize(FRAME_WIDTH, FRAME_HEIGHT);
          frame.setVisible(true);
     public void itemStateChanged(ItemEvent e3)
          Object source = e3.getItem();
          if(source == answer1)
                    int select = e3.getStateChange();
                    if(select == ItemEvent.SELECTED)
                              answer1Int = 1;
                    else
                              answer1Int = 0;
          else if(source == answer2)
                    int select = e3.getStateChange();
                    if(select == ItemEvent.SELECTED)
                              answer2Int = 1;
                    else
                              answer2Int = 0;
          else if(source == answer3)
                    int select = e3.getStateChange();
                    if(select == ItemEvent.SELECTED)
                              answer3Int = 1;
                    else
                              answer3Int = 0;
          else
                    System.out.println("Error");
     public void  actionPerformed(ActionEvent e)
          if(e.getSource() == button)
               if(count == 0)
                         if(answer3Int == 1 && answer2Int == 0 && answer1Int == 0)
                                   score = 5;
                         else if(answer3Int == 1 && answer2Int == 1 && answer1Int == 0 || answer3Int == 1 && answer2Int == 0 && answer1Int == 1)
                                   score = 2;
                         else if(answer3Int == 1 && answer2Int == 1 && answer1Int == 1)
                                   score = 1;
                         else
                                   System.out.println("Error");
               totalScore = (totalScore + score);
               System.out.println(totalScore);
               System.out.println("1: " + answer1Int + "  2: " + answer2Int + "  3: " + answer3Int);
               if(count == 1)
                         questionString = ("The first American chess tournament was held in what state?");
                         question.setText(questionString);
                         score = 0;
                         if(answer3Int == 0 && answer2Int == 1 && answer1Int == 0)
                                   score = 5;
                         else if(answer3Int == 1 && answer2Int == 1 && answer1Int == 0 || answer3Int == 0 && answer2Int == 1 && answer1Int == 1)
                                   score = 2;
                         else if(answer3Int == 1 && answer2Int == 1 && answer1Int == 1)
                                   score = 1;
                         else
                                   System.out.println("Error");
                    totalScore = (totalScore + score);
                    System.out.println(totalScore);
                    ++count;
}

Similar Messages

  • There is no option to reject an incoming call in locked screen, there must be an icon on the screen for one who don't want to use lock button several times, i did'nt face this problem in last ios 6.1.3.

    There is no option to reject an incoming call in locked screen, there must be an icon on the screen for one who don't want to use lock button several times, i did'nt face this problem in last ios 6.1.3.

    A good read. Have you done anything at all to resolve your problem. Reset? Restore?
    By the way - "your products"... nobody here produced the iPhone, we are all just users. Apple is not here.

  • My phone won't turn on. I have tried the Power button   home button several times and even held it for over 3 minutes.. When I plug it in it still won't respond to itunes PLEASE HELP!! A little water got in it but it was like a drop or two..

    My Iphone 4g, won't turn on, I have tried the power button + home button several times and held them for over 3 minutes. It won't even respond to Itunes and I can't restore it because of that. A little water got into it before it completely shut off but it was like little drops.. Please HELPP.
    I also have tried  to put it in rice and left it there for 9 hours and it still doesn't work

    A drop or two of water may have been enough to cook it. If it was bad enough to prompt you to put it in a bag of rice, then I'd venture to guess it was more than a drop or two.
    Try putting it back in the bag of rice and leave it there for several days.
    If that doesn't fix it, then you're more than likely looking at paying for an out of warranty replacement.
    Water and delicate electronics don't generally get along well.

  • Itunes was not installed correctly error 1114.  I have uninstalled and reinstalled using the steps several times., itunes was not installed correctly error 1114.  I have uninstalled and reinstalled using the steps several times.

    itunes was not installed correctly error 1114.  I have uninstalled and reinstalled using the steps several times., itunes was not installed correctly error 1114.  I have uninstalled and reinstalled using the steps several times.
    I have never been so close to packing the whole lot up and sending the ipad back!
    Please help!
    Kieran

    Issues installing iTunes or QuickTime for Windows
    iTunes 11.1.4 for Windows: Unable to install or open
    Troubleshooting issues with iTunes for Windows updates

  • I have to push the button several times for my phone to come on has this happened to anyone else?

    I have to push the button several times for the phone to come on - has anyone else had this problem?

    I have to push the button several times for the phone to come on - has anyone else had this problem?

  • RMBP: Sometimes, after having been shut down, i have to press the power button several times before the machine starts up. It's 3 weeks old, and this has happened 2 times now. Is there something wrong with my rMBP?

    rMBP: Sometimes, after having been shut down, i have to press the power button several times before the machine starts up. It's 3 weeks old, and this has happened 2 times now. Is there something wrong with my rMBP?

    Did you purchase the Mac new?
    You have 14 calendar days from the time your items are delivered to initiate a return as noted here.
    Even though you are past the 14 day limit, if it were me, I'd take the Mac back and explain what's going on. Your Mac should work out of the box.
    message edited by:  cs

  • I have an iPhone 4 and since I updated to iOS6 I must hit the home button several times to return home or sometimes turn off and then back on. Any thoughts? Could this be related to running low on available storage?

    I have an iPhone 4 and since I updated to iOS6 I must hit the home button several times to return home or sometimes turn off and then back on. Any thoughts? Could this be related to running low on available storage?

    Hold the sleep/wake button and the home button until the phone shuts down and let it restart.

  • I have to press my home button several times before it responds.  How do i fix this?

    I have to press my home button several times before it responds and takes me to the home page.  How do i fix this?

    Bring your phone in for service.

  • When I try to play a flash video (like youtube) i have to click a flash button several times before it works. Why do flash videos not recogonize any clicks without several tries first?

    When I try to go to a flash video, the video player never seems to recognize my mouse clicks without several tries.
    It's hard to explain but if I'm at a youtube video and i place my cursor over the button that lets you skip around the video, the cursor will alternate being a cursor (like its not recognized) and a hand like its supposed to. It's sort of keeps flickering between the two if I move the mouse around on that little skip button.
    I tried uninstalling firefox but it didn't make a difference. I noticed it after updating to the newer firefoxe updates. This does not happen under IE.
    thank you for your help.

    '''[https://support.mozilla.org/en-US/kb/troubleshoot-firefox-issues-using-safe-mode Start Firefox in Safe Mode]''' {web link}
    While you are in safe mode;
    Press the '''Alt''' or '''F10''' key to bring up the tool bar.
    Followed by;
    Windows; '''Tools > Options'''
    Linux; '''Edit > Preferences'''
    Mac; ''application name'' '''> Preferences'''
    Then '''Advanced > General.'''
    Look for and turn off '''Use Hardware Acceleration'''.
    Poke around safe web sites and see if there is still a problem. Then restart.

  • Photoshop CS6 gets AppHang when using Magnetic Lasso Several Times

    My operating system is a Dell Precision T3500 Windows 7 64-bit SP1 6GB RAM.
    I opened a 102MB tif file which had been created in Lightroom4 by telling LR to edit in Photoshop.  I already had a small .jpg open in one window -- I am using tabbed layouts. 
    I Used the magnetic lasso about four times to delete sections of the photo and replace them with a Pattern (grey backround).  Several of the mask selections were to the border of the photo and I moved the curor for the lasso beyond the border of the photo. Then I used the polygon lasso two or three times to replace additional sections which had been left behind.  I went back to the magnetic lasso.  When I went outside the boundaries of the photograph this time, CS6 hung.  I couldn't switch windows or do anything in Photoshop.  Dead.  The task manager said the program wasn't responding, and I used the task manager to kill it.

    You could simply reach the limit of allowed points in a path. You will have to use multiple passes/ segemnts. I don't see why this should be a problem. Selections are selections. The path is merely a temporary representation of the selection border, the actual selection is pixel based, no matter what. Maybe look up a tutorial on how to work with saved selections/ channels? Just saying... Seems to me like you're trying to outsmart the program and doing everything in one go, which arely ever works...
    Mylenium

  • I Synced two of my computers and the Sync was interrupted and now I don't have all the tabs I wanted transferred. How do I redo the Sync? I've clicked the Sync Now button several times and nothing seems to happen.

    I Synced two laptops, mostly to transfer several tab groups open in one to the other. While the Sync was in progress, the Options window started to vibrate. After a while, I closed the window and then Firefox. After restarting Firefox, I found that only a few tabs and little of the history had been transferred. I clicked the Sync Now button, on both devices, but nothing further has happened so far.

    iPod touches or any iDevices from Apple sync only to one computer. If you sync to a different computer, all your music will be replace with the music from the new computer's iTunes. If the music were purchased from iTunes, you can re-download them again otherwise the music on iPod touch will be deleted. Do you have iTunes backup? 

  • HT4623 My iphone 5 will not update apps, is stuck in "waiting", reset using soft reset several times, then went into settings, general and reset twice, still frozen apps in waiting and will not update anymore.

    Iphone 5 will not update apps. s
    Stuck in "waiting" even after multiple resets to phone and through settings. HELP!

    Have you tried deleting the waiting apps and then re downloading? I used to get it all the time on my phone in iOS 7.

  • HT1420 I've used this computer several times to purchase music and now they are asking me to register it again and provide answers to my security questions which I did and they say they are invalid when I know they aren't - all I want to do is download so

    Every time I try to purchase any music now it asks for security questions to verify my identity and when i put in the two answers it says one or more answers are incorrect which is NOT true -

    See Here > Apple ID: Contacting Apple for help with Apple ID account security
              Ask to speak with the Account Security Team...
    Or Email Here  >  Apple  Support  iTunes Store  Contact
    More Info >  Apple ID: All about Apple ID security questions
    Note:
    You can only set up and/or change a Rescue Email Before you forget the questions/answers.

  • Apple logo appears after pressing menu several times

    I just bought my 30gb ipod less than a week ago, and its has had this problem from the start. Often, after I turn it on, it shows the apple logo and does its startup procedure for like 30 seconds. It also sometimes will do that if I am playing a song and then decide to go to the very top menu by pressing the menu button several times quickly. Both things get very annoying, and any help is greatly appreciated. I used to have a 4th gen ipod and it never did this.
    thanks in advance

    Welcome to Apple Discussions!
    If it shows the Apple logo when you turn it on and you haven't used it for over 14 hours, that is normal. See this for more info...
    About Sleep, Deep Sleep, Hibernation, and Sleep Timer
    As for the iPod resetting when you click menu several times, that is not normal.
    Make sure that all the software on the iPod and computer is up to date...
    iTunes
    iPod Updater
    Updating iPod's Software
    Also, try these...
    Resetting iPod
    Restore the iPod
    btabz

  • Help - HP Pavilion a6030.uk desktop. Have to press the power button multiple times to start up?

    Hi, 
    I have a HP desktop computer. The model is HP Pavilion a6030.uk, Opertating system: windows vista.
    My computer has had no problem at all until yesterday for some reason i  had to push the power button multiple times to start it until it finally turned on and did the normal start up. Such as i would press the power button as normal to start it, but all of a sudden, it would turn off after about 2 seconds, and so I would press the power button several times and each time it would not start up and turn off, so the power button would be pressed again until it would finally turn on and start up and run as normal and seems to work fine. And it was the same today, i pressed the power button mutiple times (e.g. 6 times) until it finally started as normal.
    As im not very knowledgeable or very computer/technology savvy wise in this area, please will someone help me and give me some advice/help to fix/solve this.
    Thankyou for taking time to read this and any help would be much appreciated to resolving this problem.
    Thanks.
    This question was solved.
    View Solution.

    Vonbon90, welcome to the forum.
    When I see these symptoms on an older computer, I believe that it may be a failed/ing power supply unit (PSU).  Here is a guide that will help your troubleshoot it.
    Also, you could test the memory.  This can be done by removing all of the memory modules and replacing them one at a time and booting.
    Please click the " Thumbs up + button" if I have helped you and click "Accept as Solution" if your problem is solved.
    Signature:
    HP TouchPad - 1.2 GHz; 1 GB memory; 32 GB storage; WebOS/CyanogenMod 11(Kit Kat)
    HP 10 Plus; Android-Kit Kat; 1.0 GHz Allwinner A31 ARM Cortex A7 Quad Core Processor ; 2GB RAM Memory Long: 2 GB DDR3L SDRAM (1600MHz); 16GB disable eMMC 16GB v4.51
    HP Omen; i7-4710QH; 8 GB memory; 256 GB San Disk SSD; Win 8.1
    HP Photosmart 7520 AIO
    ++++++++++++++++++
    **Click the Thumbs Up+ to say 'Thanks' and the 'Accept as Solution' if I have solved your problem.**
    Intelligence is God given; Wisdom is the sum of our mistakes!
    I am not an HP employee.

Maybe you are looking for

  • SD Billing doc was not created

    Hi, we have a sales document and the status of  order is completed.But the invoice hasn't created.It shows  Account determination error.It is not creating the Acc doc. what could be the possibilities?? Krish.

  • Progress tracking

    Hello Friends, please let me know how to monitor the status of PO till GRN, that is Progress tracking and set the events with offset days; Thanks

  • Preloader and Loading External Flash issue

    Source File: http://cratle7.googlepages.com/loader.fla View Swf File: http://cratle7.googlepages.com/loader.html I need to start an ad from Mochiads in the first frame and then load a game in the second frame. The current issues are: 1. After loading

  • APEX 4 Interactive Report set font color of negative values to red

    I have an interactive report with several columns containing numerical values. If the value is negative, I want the font color to be red. Can someone help me with this process please. Application Express 4.1.1.00.23 Thanks! Chris

  • Problem in leadselection of a Basic TableUIElement

    HI Experts, i have created two views in first view  i have some table data . now i need to get the on lead selected row values in next view . For this one i mapped both views to same node and attributes through Component controller. With this one i a