I want to create a showOptionDialog using JOptionPane that has two buttons: Metric and Imperial.
If say, Metric is clicked on, the Metric GUI will load. Conversely, if Imperial is clicked on, then the Imperial GUI will load.
How do I do this?
int choice = JOptionPane.showOptionDialog(null, //Component parentComponent
"Metric or Imperial?", //Object message,
"Choose an option", //String title
JOptionPane.YES_NO_OPTION, //int optionType
JOptionPane.INFORMATION_MESSAGE, //int messageType
null, //Icon icon,
{"Metric","Imperial"}, //Object[] options,
"Metric");//Object initialValue
if(choice == 0 ){
//Metric was chosen
}else{
//Imperial was chosen
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With