The following code piece must display correct message in GUI according conditional statement. When tested using void main, I get the result as expected. However, when I test using applet the result is OK for the first if(....) statement but freezes on the second.
- if condition OK then compute result
- if condition not suited then display error and user tries again (the program is stuck here)

I cannot find the cause so please help me troubleshoot.

public class BridgeGame extends JApplet implements ActionListener {
      // Need to solve for range x=1~13 and y=1~52    
      static long x;
      static long y;   
      public void actionPerformed(ActionEvent event) {
         long xLimit = 13;
         long yLimit = 52;
         boolean correct = false;
         do {
            x = Integer.parseInt(inputX.getText());
            y = Integer.parseInt(inputY.getText());
            inputX.setText("0");
            inputY.setText("0");
            outXvalue.setText("X value (1 ~ 13): = " + x);
            outYvalue.setText("Y value (1 ~ 52): = " + y);			
            // Set user entry limitations and keeps program active
         	// until user enters values within limits
            if (x <= xLimit && y <= yLimit && x != 0 && y != 0) {
               correct = true;
            }
            if (correct) {
               message.setText("Possible combinators are = " + Combinations(y, x));
            }
            else {
               message.setText("Sorry limits exceeded");
            }
         }
         while (!correct);
         if (!correct) {
         }
      }

delete lines 9 and 28 - do not use do-while loop here

delete lines 9 and 28 - do not use do-while loop here

Funny how that works? Problem solved but once again, the conventions eludes me. I used the do { while loop } precisely to keep the program active until the correct values are entered without prematurely terminating the program. Yet it needed to be deleted when tested using applet.

As a side note, could you explain why the do { while loop } worked with the static void main method of testing and not needed using the applet method for testing? The solution to my question seemed so elementary and am thinking I should know this but cannot come up with an answer why I should...just does not show up explicitly in any of the rules I have learned.

Thanks again very much,
Jems

When you run java file in JVM, some threads are run.
Check them using jstack.exe command (-path- ..\jdk1.7.0\bin )
Compare execution of GUI-application and simple command line program without awt/swing GUI.
This and other tools described here http://www.herongyang.com/Java-Tools/jstack-JVM-Thread-Dump-Stack-Strace.html

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.