阅读背景:

如何等待来自一组JRadioButtons的输入? (JAVA)

来源:互联网 

I have a class that is a JPanel and implements ActionListener. On the panel, there are three JRadioButtons, and when the user selects one of them, the user's score is incremented based on which radio button they selected. (This works- I tested it out by adding an instance of this class to a simple JFrame). When running my game, though, I have a JFrame Menu class with four options. When the user selects the "Play" option, I create a new instance of my JPanel and add it to the JFrame. However, this program does not wait for me to select a radio button- it finishes execution before I select any of the radio buttons. I have tried using a while loop that checks if a boolean is true (meaning that I selected a radio button) but this just makes my radio buttons unclickable. Is there any way to make the program wait for you to click a radio button before continuing execution? (Yes, I added actionListeners to the radio buttons!)I have a class that is a JPanel and implements




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: