Reputation: 377
Hello I've problem in reloading JDialog
.
I've 2 JRadioButton:
When I click a button, a dialog will appear, it's content will depend on the radio button. If I choose the first one it will display "Hello World!", but if I choose the second will display "Hello Community!". But the dialog won't change, just display the content based on what I choose first.
Here is my button action:
txtResult.setText(radioOption.getSelectedItem().toString());
JDialog jd = new JDialog();
jd.setSize(600,400);
jd.setVisible(true);
Upvotes: 0
Views: 1003
Reputation: 68
Try putting jd.dispose(); at the end of your code. This will remove the message object.
Upvotes: 0
Reputation: 2616
Try this:
JOptionPane.showMessageDialog(frame, radioOption.getSelectedItem().toString());
In above code frame
is owner window
EDIT :
And in your code as you have commented txtResult
is JTextField
so the radioOption
text will display on JTextField
not on any dialogbox
Upvotes: 2
Reputation: 5399
There is documentation and I suggest you (not just you) try to read before write any code, Link to examples first line your example, link to doc
Upvotes: 1