I have made a panel which contains two radio groups of buttons. You can find the result of JPanel
in the image below. Then I used the below code to add this panel to a JOptionPane
box:
OptionsForDisjunctionNodes optionsForDisjunctionNodes=new OptionsForDisjunctionNodes();
JPanel p=optionsForDisjunctionNodes.getPanel();
int option = JOptionPane.showConfirmDialog(null, p, "Decision on Disjunctive Nodes", JOptionPane.OK_CANCEL_OPTION,JOptionPane.INFORMATION_MESSAGE);
if (JOptionPane.OK_OPTION == option) {
// Print selected radio button in each group. How?
} else {
// Do something else.
}
Let's say the name of group boxes are buttonGroup1
, and buttonGroup2
I need to when the user click on Ok button, I print the selected label in both groups