Share this page 

Customize JOptionPane buttonsTag(s): Swing


String[] buttons = {"Yes", "Yes to all", "No", "Cancel"};

int rc = JOptionPane.showOptionDialog(null,
   "Do you really want to delete this file [" + filename + "]?",
   "Confirmation",
   JOptionPane.WARNING_MESSAGE,
   0,
   null,
   buttons,
   buttons[2]);

if (rc==-1) {
   System.out.println("Dialog closed without clicking a button.");
   }
else {  
   System.out.println(buttons[rc] + " was clicked");
   }