Object[] options = {"Metric","Imperial"}; int n = JOptionPane.showOptionDialog(null, "A Message", "A Title", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.DEFAULT_OPTION, null, options, options[1]); System.out.println(n); JFrame metric = new JFrame("Metric"); metric.setBounds(0, 0, 320, 240); JFrame imperial = new JFrame("Imperial"); imperial.setBounds(0, 0, 320, 240); if(n==0){ metric.setVisible(true); }else if(n==1){ imperial.setVisible(true); }else{ System.out.println("no option choosen"); }
source share