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) {
}
}