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");
   }



If you find this article useful, consider making a small donation
to show your support for this Web site and its content.

Written and compiled by Réal Gagnon ©1998-2011
[ home ]