W2R3 – Update the JRadioButton name
This commit is contained in:
1 parent
dffe04254f
commit
463edee561
1 file changed
+10
-3
@@ -67,15 +67,22 @@ public class MainViewer {
|
|||||||
panel.add(JT);
|
panel.add(JT);
|
||||||
|
|
||||||
|
|
||||||
JOptionPane pane = new JOptionPane(panel, 3, 2); // content of dialogue box
|
//JOptionPane pane = new JOptionPane(panel, 3, 2); // content of dialogue box
|
||||||
|
JOptionPane pane = new JOptionPane(panel, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION);
|
||||||
JDialog dialog = pane.createDialog("Rename Dialogue Box"); // title of dialogue box
|
JDialog dialog = pane.createDialog("Rename Dialogue Box"); // title of dialogue box
|
||||||
dialog.setVisible(true); // changed boiler plate code from .show() to .setVisible(true) because apparently IDE says it's better!!
|
dialog.setVisible(true); // changed boiler plate code from .show() to .setVisible(true) because apparently IDE says it's better!!
|
||||||
|
|
||||||
// actions.
|
// actions.
|
||||||
|
|
||||||
|
int choice = (int) pane.getValue();
|
||||||
|
|
||||||
|
if (choice == JOptionPane.OK_OPTION)
|
||||||
|
{
|
||||||
|
System.out.println("OK option pressed.");
|
||||||
|
JR.setText(JT.getText());
|
||||||
|
} else if (choice == JOptionPane.CANCEL_OPTION) {
|
||||||
|
dialog.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user