Help please--cannot get summary button to work???!!!!

Hi all,
I am trying to get a summary of results on a survey, and I did have a portion of it working, but needed to add more code to complete it.
When I hit the display summary button--nothing happens. There is a problem with my logic, but no logic errors come up. I must have created an infinite loop.
Your help is much appreciated!!!!!
Here is the code
rivate void summaryJButtonActionPerformed( ActionEvent event )
       //declare variables
       double perAgree = 0.00;
       double perDisagree = 0.00;
       double perNuetral = 0.00;
       //calculate percent response for each category
       perAgree =  ((double)numAgree/total) * 100;
       perDisagree = ((double)numDisagree/total ) * 100;
       perNuetral =  ((double)numNuetral/total) * 100;
       //clear old results
              summaryJButton.setText("");
       //add header to output area
       resultsJTextArea.append( "RESPONSE\tFREQUENCY\tPERCENT\tHISTOGRAM");
       //display results
       resultsJTextArea.append("\n" + "Agree" + "\t" + numAgree + "\t" + perAgree + "%"  );
       resultsJTextArea.append("\n" + "Disagree" + "\t" + numDisagree + "\t" + perDisagree + "%"  );
       resultsJTextArea.append("\n" + "No Opinion" + "\t" + numNuetral + "\t" + perNuetral + "%"  );
       do
            if (numAgree < total)
                 resultsJTextArea.append("\t" + "\t" + "\t" + "*");
            if (numDisagree < total)
                 resultsJTextArea.append("\t" + "\t" + "\t" + "*" );
            if (numNuetral < total)
               resultsJTextArea.append("\t" + "\t" + "\t" + "*");
      } while (numAgree + numDisagree + numNuetral <= total);
   } // end method summaryJButtonActionPerformed
/code]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Hi and thanks for your help!
I did invoke the method with a handler. Maybe I should have given you the entire code that I have in the first place.
The first part of the code, and the other method seems to be working, so I was focusing on where the problem is.
By the way- tried the system.out.printli, but since nothing happens when I click the summary button, I cannot even get any values to print in the command prompt.
Here is the entire app:
// Application summarized results of a survey
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.text.DecimalFormat;
public class Survey extends JFrame
   // JLabel and JTextField read response
   private JLabel responseJLabel;
   private JTextField responseJTextField;
   // JButton initiates display of results
   private JButton summaryJButton;
   // JTextArea for survey results
   private JTextArea resultsJTextArea;
   // JButton resets to start again
   private JButton resetJButton;
   // DECLARE COUNTERS FOR VALID RESPONSES
   private int numAgree = 0;
   private int numDisagree = 0;
   private int numNuetral = 0;
   private int total = 0;
   // no-argument constructor
   public Survey()
      createUserInterface();
   // create and position GUI components; register event handlers
   private void createUserInterface()
      // get content pane for attaching GUI components
      Container contentPane = getContentPane();
      // enable explicit positioning of GUI components
      contentPane.setLayout( null );
      // set up responseJLabel
      responseJLabel = new JLabel();
      responseJLabel.setBounds( 116, 8, 70, 23 );
      responseJLabel.setText( "Response:" );
      contentPane.add( responseJLabel );
      // set up responseJTextField
      responseJTextField = new JTextField();
      responseJTextField.setBounds( 215, 8, 70, 23 );
      contentPane.add( responseJTextField );
      // ADD THE ACTION LISTENER TO THIS FIELD
      responseJTextField.addActionListener(
                new ActionListener() // anonymous inner class
                    // event handler called when user clicks responseJButton
                    public void actionPerformed ( ActionEvent event )
                       responseJTextFieldActionPerformed( event );
                } // end anonymous inner class
             ); // end call to addActionListener
      // set up summaryJButton
      summaryJButton = new JButton();
      summaryJButton.setBounds( 116, 40, 170, 26 );
      summaryJButton.setText( "Display Summary" );
      summaryJButton.setEnabled(false);
      contentPane.add( summaryJButton );
      summaryJButton.addActionListener(
                new ActionListener() // anonymous inner class
                    // event handler called when user clicks summaryJButton
                    public void actionPerformed ( ActionEvent event )
                       summaryJButtonActionPerformed( event );
                } // end anonymous inner class
             ); // end call to addActionListener
      // set up resultsJTextArea
      resultsJTextArea = new JTextArea();
      resultsJTextArea.setBounds( 16, 78, 400, 100 );
      resultsJTextArea.setEditable(false);
      contentPane.add( resultsJTextArea );
      // set up resetJButton
      resetJButton = new JButton();
      resetJButton.setBounds( 175, 200, 70, 23 );
      resetJButton.setText( "reset" );
      contentPane.add( resetJButton );
      // ADD THE ACTION LISTENER TO THIS BUTTON
      resetJButton.addActionListener(
                new ActionListener() // anonymous inner class
                    // event handler called when user clicks resetJButton
                    public void actionPerformed ( ActionEvent event )
                       resetJButtonActionPerformed( event );
                } // end anonymous inner class
             ); // end call to addActionListener
      // set properties of application's window
      setTitle( "Survey Summary" ); // set title bar text
      setSize( 450, 275 );         // set window size
      setVisible( true );          // display window
   } // end method createUserInterface
   // method reads user input and accumulates totals
   private void responseJTextFieldActionPerformed( ActionEvent event )
        String input;             //used to store user's input
        boolean valid;
        int response;
          //test for no input
        if (responseJTextField.getText().equals(""))
                          JOptionPane.showMessageDialog( null,
                        "Please enter a response to the survey ", "Message",
                         JOptionPane.INFORMATION_MESSAGE);
                             return;
          //read user input and convert to number
        input = ( responseJTextField.getText() );
        response = Integer.parseInt (input);
        // display error when response is not valid
                  if (response == 1 || response == 2 || response == 3)
                    valid = true;
                    total++;
                    summaryJButton.setEnabled (true);
                    responseJTextField.setText("");
               else
                    //display error message
                    JOptionPane.showMessageDialog( null,
                  "Please enter a valid response ", "Message",
                   JOptionPane.INFORMATION_MESSAGE);
                   return;
             //add totals for each category
             if (response == 1)
                    numAgree++;
               if (response == 2)
                    numDisagree++;
               if (response == 3)
                    numNuetral++;
   } // end method responseJTextFieldActionPerformed
   // method displays survey summary
   private void summaryJButtonActionPerformed( ActionEvent event )
       //declare variables
       double perAgree = 0.00;
       double perDisagree = 0.00;
       double perNuetral = 0.00;
       //calculate percent response for each category
       perAgree =  ((double)numAgree/total) * 100;
       perDisagree = ((double)numDisagree/total ) * 100;
       perNuetral =  ((double)numNuetral/total) * 100;
       //clear old results
              summaryJButton.setText("");
       //add header to output area
       resultsJTextArea.append( "RESPONSE\tFREQUENCY\tPERCENT\tHISTOGRAM");
       //display results
       resultsJTextArea.append("\n" + "Agree" + "\t" + numAgree + "\t" + perAgree + "%"  );
       resultsJTextArea.append("\n" + "Disagree" + "\t" + numDisagree + "\t" + perDisagree + "%"  );
       resultsJTextArea.append("\n" + "No Opinion" + "\t" + numNuetral + "\t" + perNuetral + "%"  );
       do
            if (numAgree < total)
                 resultsJTextArea.append("\t" + "\t" + "\t" + "*");
            if (numDisagree < total)
                 resultsJTextArea.append("\t" + "\t" + "\t" + "*" );
            if (numNuetral < total)
               resultsJTextArea.append("\t" + "\t" + "\t" + "*");
      } while (numAgree + numDisagree + numNuetral <= total);
   } // end method summaryJButtonActionPerformed
   // method resets and clears to enable re-start
   private void resetJButtonActionPerformed( ActionEvent event )
        numAgree = 0;
        numDisagree = 0;
        numNuetral = 0;
        total = 0;
       responseJTextField.setText( "" );
      resultsJTextArea.setText( "" );
      summaryJButton.setEnabled(false);
   } // end method resetJButtonActionPerformed
   // main method
   public static void main( String[] args )
      Survey application = new Survey();
      application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
   } // end method main
} // end class Survey

Similar Messages

  • Cannot Get Animated Buttons to Work in DPS (InDesign 6.0) Help Please!!

    In DPS tips, using the iPad app, some of the navigational buttons appear like SWF buttons, but, I cannot get SWF buttons to work in DPS. I have been trying with Multi-States, but, cannot get that to work either. Can you tell me how to get a SWF like button to work in DPS - I'm working with ID 6.0.
    Do you have an eaasy answer? Is there a tutorial out there I can view? Is their a step-by-step I can read?
    BTW, I do understand how buttons work and the types of events that work in DPS.
    Thank you
    Lain Kennedy

    Hi Uwe,
    First, let me say "I cannot even believe all the wonderful information I have recieved from my original post," and, I want to thank you for your understanding.
    I have been a designer for many years, working before the computer, and, since the mid 80's working with a variety of software to produce both print and web projects. I must say, I am biased on the Adobe Creative Suite, and, have had amazing success with these tools.
    Nonetheless, I have been working with DPS for about a month now (and a month does not make a career), and, have to admit, I am looking at DSP as a Hybrid between Print and Web. Yet, it is neither print or wed, it is it's own element, and, I'm just having growing pains learning, especially the terminology.
    Yes, I am trying to explain SWF Buttons, when in reality, it is DPS Buttons, and, my thinking is based on print and web. Now, it is - in some ways - like going back to school learning DPS and DSP terminology. It is a bit frustrating, but, I know I will get it.
    Now that I have looked at my first MSO test, I followed the instructions in DPS Tips, I realize that the Button is in the "Normal State" as I (interact, this is my terminology) touch or hover to make the button work. It is in the "Click" state that the Button triggers the MSO to work, and, I finally get that now - okay, I'm slow to learn. And, I will be building a complex MSO to prove the point to myself.
    I was wondering, besides DPS Tips, are there any books, apps, specific sites that are very specific on "ALL" the things one can do with DSP? 
    Again, thank you and, all the folks who have taken their time to respond to my post. All the information is truly appreciated.
    Sincerely,
    Lain Kennedy

  • Help please - cannot get IP address

    Hi everyone, I have a WRT54GS router with WEP encryption. I have 2 laptops, both with XP. I cannot get one of the laptops to get an IP connection. It connects to the router, but when I run ipconfig, I get the following error message Windows IP Configuration An internal error occured. A device attached to the system is not functioning. Please contact Microsoft product support services for further help. I have many years of IT experience, and I've also had my network admin brother help me, but we can't figure it out. I have entered the WEP address correctly and have unchecked the box "Key is provided for me automatically". The key index is the same on both PC's. We have released the IPconfig. The PC that can't connect has been recently acquired and has never successfully got an IP connection on this wireless LAN. Any suggestions greatly appreciated. Thanks so much, Lynne

    Sounds like an issue on the computer itself not the network. You might need to uninstall reinstall your wireless card.

  • I cannot get my @ button to work on the iMac why is this not working?

    Cant get the @ button on my iMac to wwork is there another way to get it to work other than the usual way of shift up and @

    If you have access to another keyboard, you could see if the issue is really in that,
    or if the problem could have some other cause... Even a PC keyboard may help
    to troubleshoot this one aspect. I try to always have a spare USB keyboard/mouse.
    Not sure if you could re-assign other keys, such as the F_ keys across the top, to
    have a different one for the @ symbol. There is a code for each one of those items
    and you could use it, or have a text document handy to copy-paste that one item.
    And if you have an antique iMac, or a newer intel-based one, they have different
    operating systems; and troubleshooting may take on different dimensions, too.
    So advice and results may vary depending on hardware & software in use.
    Good luck & happy computing!

  • Please help, I cannot get play menu to work after using dynamic link.

    Ok. So I sent a video from premiere pro to encore using dynamic link. Then I created a menu in encore and dragged video to play button I created for the dvd. However, when I burn the dvd, the menu is not a part of the DVD. I do not know why this happens when I use a dynamic linked video. It does not happen when I use other videos. Please help. Thanks Matt

    You need to set the menu to be first play.
    If you create a timeline before you add a menu, the timeline becomes first play. If you set the end action of the timeline to the menu, it will eventually get there, but that does not appear to be what you want.

  • Cannot get Submit button to work

    I am really stumped with this one. The Submit to Manager button is not working. The only error I get is that assocID is not identified, but as far as I can tell it is identified.
    Any help would be appreciated.
    Thanks,
    MDawn

    I think the variable names may be causing a problem. I commented out the variable names, and it worked correctly, except for name. I had to change it to empName instead. Then that one worked. There's a good bit of overlap between your variable names and object names. (e.g., var assocID = assocID.rawValue) That was causing problems, too.
    Here's what I ended up doing to make the alerts/email work:
    //Create a variable to hold the document object
    var empname = empName.rawValue;
    var jobtitle = jobTitle.rawValue;
    var mgrname = mgrName.rawValue;
    var associd = assocID.rawValue;
    var accvachrs = accVacHrs.rawValue;
    //NAME
    if (empName.isNull){
              xfa.host.messageBox( "Please enter your name" );
              xfa.host.setFocus("page1.empName");
    //JOB TITLE
    else {
                        if (jobTitle.isNull){
                                  xfa.host.messageBox( "Please enter your job title" );
                                  xfa.host.setFocus("jobTitle");
    //MANAGER'S NAME
                        else {
                                  if (mgrName.isNull){
                                            xfa.host.messageBox( "Please enter a your manager's name" );
                                            xfa.host.setFocus("mgrName");
    //ASSOC ID
                                  else {
                                            if (assocID.isNull){
                                                      xfa.host.messageBox( "Please enter your Associate ID" );
                                                      xfa.host.setFocus("assocID");
    //ACCRUED VAC HOURS
                                            else {
                                                      if (accVacHrs.isNull){
                                                                xfa.host.messageBox( "Please enter your accrued vacation hours" );
                                                                xfa.host.setFocus("accVacHrs");
                                                      else {
                                                                page1.Button4.execEvent("click");

  • Need Help!  Cannot get SourceControl3.1  to work correctly.

    We are using RH8.  We have a project that needs updating to be current with newest software release.  There is a project manager in the home office and a technical writer working remotely in another state.  Our IT staff followed all the steps listed on setting up the SourceControl and this is what is occurring:
    I've tried it both as file system and as full embedded database solution. For files based solution I did create a history path. This is what I was working on Friday.  I had to set up another test machine here with RoboHelp in order to test it.  Same problem.  I can check out from either machine and checkin in. However the changes never get propagated to the other instance, even if you do a Get All. 
    Not sure if this is related, but the open project from Source Control does not work from within Robo Help 8 either. When I try to open a project that way, it just sits there on the open file dialog box.  From what the tutorial showed, it should start downloading the files and then you select the project file to open.
    Here's a sample screen shot. 
    I setup a brand new test database and project
    This one is using embedded database, not stored as files.
    Files are set to single checkout
    I modified on one machine
    Checked in ALL files
    Open project on other machine and get all files
    Changes not reflected
    Forced Get All
    Changes not reflected
    Here it is in the project directory... note the mod dates... the file is not updated.
    I would be so very grateful if someone could help figure out what is going on.  Thank you in advance.
    Stella

    Hello my friend. Try to go to the Volume options and click the advanced button on the play control.Check the enable digital I/0 box. If it worked let me know.Good luck.Message Edited by pangef on 07-8-2006 06:58 AM

  • Help! Cannot get Twitter Widget to Work!

    Hello,
    I am running Adobe Captivate 6 on a Mac. i have MAMP installed and followed the Twitter Widget installation guide here:
    http://help.adobe.com/en_US/captivate/cp/using/WSedb8e841cbc0b796-1c6e 5ece129f9bd28c5-8000.html
    When I preview my project in captivate or in web browser the widget does not show, neither does it when I publish the project to my local "test" moodle.
    The widget "icon" appears in the edit window.
    I think utilizing this tool in an elearning environment is an awesome concept and have been wracking my brain to figure it out.
    Any help would be greatly appreciated.
    Thanks,
    Josh

        Having issues with making and receiving calls can cause a lot of frustration Jamesgirl. I'm sorry your network extender isnt working properly but no worries because we are here to help. How long have you had issues with this accessory? Whats your zipcode and phone types? I recommend power cycling the Network extender. Keep us posted.
    KinquanaH_VZW
    Follow us on Twitter @vzwsupport

  • I cannot get my FaceTime to work since last two updates n my phone

    please help, i cannot get my facetime to work anymore, to contact my son

    If the problem started recently and if your phone is up to date, the problem may be with your son's phone not being up to date. More info: http://support.apple.com/kb/TS5419

  • HT4527 Help I cannot get home sharing on to my I pad

    Help I cannot get home sharing to work on my I pad purchased yesterday

    On your computer's iTunes you've turned on home sharing via File > Home Sharing, and in the Sharing tab in Edit > Preferences you have the 'share library' tickbox ticked (I use a Mac, but I assume that it's similar for PCs) :
    On my iPad I'm logged into the same account via Settings > Videos > Home Sharing, both my computer and iPad are connected to the same network (and iTunes on my computer is open), and at the top of the Videos app I get an extra tab :
    You are not seeing the Shared tab in Videos ?

  • Cannot Get U460 Webcam To Work!!! Help Please!!!

    I received my U460 a couple of days ago and I cannot get the webcam to work, at the bottom is the error I keep receiving in Youcam, I have gone in Settings and selected Lenovo Easy Camera, and no I don't have any other programs opened using The webcam. I have tried  pushing function + esc, camera is on. Mic works fine. I have tried reinstalling the Web Cam Driver, YouCam Software, then eventually did a System Restore. Then tried it in Skype, MSN Messenger. No Luck. I have wasted so much time on this. Any help would be appreciated.
    Warning
    YouCam cannot connect to your webcam ( Lenovo EasyCamera ). Try selecting another capture device within settings, or close any applications that may be using this webcam and then restart YouCam.

    When i am trying to open ciberlink youcam it shows one warning message like.......
    Warning
    Youcam cannot connect to your webcam(Lenovo Easycamera). Try selecting another capturing device within settings, or close any applications that may be using this webcam and restart youcam.
    Please any one help me to resolve this problem.
    I did this following things but no use.
    ->uninstalled easycam drivers.
    ->restarted my laptop.
    ->os automatically detected the drivers and reinstalled.
    My OS is Win 7 Home premium 64-bit.

  • I cannot get airport extreme to work. Can you help me?

    I have a G5 Power PC. I recently purchased a macbook and an Airport Extreme. I cannot get the airport to work. Can somebody help me please??
    G5 Power PC and macbook   Mac OS X (10.3.9)   new OS X on Macbook

    I plug the ethernet from the airport to the back of the modem (a Webstar unit) from my cable provider. Then I plug the other cable from the back of the airport into my G5. Then plug in the power cord. I get lots of flashing lights - "thinkin & blinkin", but then I get a message that it cannot locate the server. Even rebooted. I've been waiting for the IT guy to call/email me back me back but no response yet. I'm guessing I may just need a new location, but I'm not wired to think IT-like (I'm a very right brained graphic designer), I I don't want to screw anything up.
    Do I need to just go through a new internet setup?
    G5 Power PC and macbook   Mac OS X (10.3.9)   new OS X on Macbook

  • I have installed Mountain Lion 10.8.2 but still cannot get email from my work exchange account. I'd appreciate any help.  Thank you.

    I have installed Mountain Lion 10.8.2 but still cannot get email from my work exchange account. I'd appreciate any help.  Thank you.

    You can go to the Apple online store and purcahse a copy of Mountain Lion.  This will give you a redemption code, which you can use to download Mountain Lion from the App Store.  Unfortuantely, I'm not aware of any other way to legally purchase it.  I have never seen Apple release Muontain Lion on DVD.
    In terms of Apple Service, they just need the serial number of the machine to check the purcahse date.  It is usually correct, to within a few weeks.  A quick Google search should give you the correct number to dial.
    I hope this helps.

  • I have installed Mountain Lion 10.8.1 but still cannot get email from my work exchange account. I'd appreciate any help.  Thank you.

    I have installed Mountain Lion 10.8.1 but still cannot get email from my work exchange account. I'd appreciate any help.  Thank you.

    I would delete the account and try to re-enter it. Also, you have to let your firm's IT department know that you want to sync work email on your personal devices before they actually work.

  • I just updated my iphone to IOS 7 and cannot get my imessage to work, it keeps saying "waiting for activation" nothing i have read online has helped me try to fix the problem. why is it doing this and how can i fix it?

    I just updated my iphone to IOS 7 and cannot get my imessage to work, it keeps saying "waiting for activation" nothing i have read online has helped me try to fix the problem. why is it doing this and how can i fix it?

    Here's a good troubleshooting article about imessage "waiting for activation".
    http://support.apple.com/kb/TS4268

Maybe you are looking for

  • Error while trying to delete a pending Work Item

    hi all, working with Identity Manager 8.1, in an attempt to delete a pending workitem through debug page, the following error eppeared ERROR: com.waveset.util.WSAuthorizationException: Delete access denied to Subject gvlachopoulos on WorkItem: WFI443

  • Migration from VIRSA 4.0 to GRC 10.0 (ARA)

    Hi Guys, We've just migrated from VIRSA 4.0 to GRC 10.0. We have only two connectors configured ECC and Finace System. Rules have been generated and we're using the standard "global" ruleset. The rules seem to be generated successfully ( I've checked

  • Suppressing zeroes after decimal

    Hi I need to suppress the zeroes after the decimal places in my form output if 00 appears after decimal. eg 123.00 shd be displayed as 123 .      123.23 shd be dispalyed as 123.23. Could anyone help me with this TIA Regards

  • Changes in production order after confirmation

    Hi all,          I have confirmed the production order & all the subsequent process are completed but still the system allows changes to the order which has status DELV. Please can anybody tell me how to control once when the production order status

  • Only about 30MByte/s on SG500X between vm and Windows Client

    Hello, I just bought 3 SG500X-48 switches and after some starting tests I try to bring them to production. I use esx 5.5 server with 8x1GB Interfaces direct connected to the switch with new cat6 cables and there are 6 virtual machines on it. On the e