I implemented a Save As dialog in Java that prompts the user if the file already exists, and I want the No option to be selected by default. How do I do this?
Here i
Use this constructor:
JOptionPane(Object message, int messageType, int optionType,
Icon icon, Object[] options, Object initialValue)
where options
specifies the buttons, and have initialValue
(one of the options
values) specify what the default is.
Update: You can call showOptionDialog
rather than showConfirmDialog
. The former takes options
and initialValue
parameters.