Mega Code Archive

 
Categories / Java Tutorial / Swing
 

Confirm Pop-Ups

the return value signifies which button the user picked. The returned value is one of the integer constants: YES_OPTION, NO_OPTION, or CANCEL_OPTION import javax.swing.JFrame; import javax.swing.JOptionPane; public class ConfirmPopUps {   public static void main(String[] a) {     JFrame frame = new JFrame();     int result = JOptionPane.showConfirmDialog(frame, "Continue printing?");     // JOptionPane.showInternalConfirmDialog(desktop, "Continue printing?");     System.out.println(JOptionPane.CANCEL_OPTION == result);   } }