I have a graphics () function that creates my JFrame and two JRadioButtons and adds ActionListeners to them. This graphic is called from main (), and the graphic itself calls the game ().
public void game() throws Exception { jTextArea1.setLineWrap(true); jTextArea1.setWrapStyleWord(true); jTextArea1.setText("This is private information."); jRadioButton1.setVisible(true); jRadioButton2.setVisible(true); try { t.sleep(40000); repaint(); } catch (InterruptedException e) {
After displaying "This is personal information." in the text area, I want the program to pause for 40 seconds, or until the user presses the JRadioButton button, whichever comes first. So I added an ActionListener and called t.interrupt () inside it.
private void jRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) { t.interrupt(); jRadioButton1.setVisible(false); jRadioButton2.setVisible(false);
However, even after choosing JRadioButton, which should cause an interrupt, this does not happen, and t.interrupted returns false.
Any help would be appreciated.
source share