I am new to Swing so this might seem like a very naive question.
I have a JFrame which displays an initial statement and two radiobuttons. RadioButton1 is Accept and RadioButton2 is Reject. If the user chooses Accept, the program proceeds. So I have created an ActionListener for Accept so that the rest of my code is within this ActionListener. However, as soon as the user presses Accept, the GUI freezes. Pressing Reject just exists out of the program.
public void game() throws Exception
{
jTextArea1.setLineWrap(true);
jTextArea1.setWrapStyleWord(true);
jTextArea1.setText("Please choose Accept or Reject");
jRadioButton1.setVisible(true);
jRadioButton2.setVisible(true);
jRadioButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButton1.setVisible(false);
jRadioButton2.setVisible(false);
repaint();
//more code
});
}
After this I make connections to the server which works fine since when I use System.out.println(), all the outputs are fine, just the GUI is frozen.
Is there a better way to continue when the user presses Accept?