public class Test extends JFrame { public Test() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
getContentPane().add(new JLabel("Placeholder label"));
pack();
setSize(200, 200);
setVisible(true);
int replaced = JOptionPane.showConfirmDialog(this,
"Replace existing selection?");
String result = "?"; switch (replaced) { case JOptionPane.CANCEL_OPTION:
result = "Canceled"; break; case JOptionPane.CLOSED_OPTION:
result = "Closed"; break; case JOptionPane.NO_OPTION:
result = "No"; break; case JOptionPane.YES_OPTION:
result = "Yes"; break; default:
;
}
System.out.println("Replace? " + result);
}
public static void main(String[] args) { new Test();
}
}