I want to change YES and NO to something like Agree/Disagree. What should I do?
int reply = JOptionPane.showConfirmDialog(null,
"Are you want to continue the process?",
"YES?",
JOptionPane.YES_NO_OPTION);
You can use the options
parameter to push custom options to showOptionDialog;
Object[] options = { "Agree", "Disagree" };
JOptionPane.showOptionDialog(null, "These are my terms", "Terms",
JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null,
options, options[0]);
You can do the following
JFrame frame = new JFrame();
String[] options = new String[2];
options[0] = "Agree";
options[1] = "Disagree";
JOptionPane.showOptionDialog(frame.getContentPane(), "Message!", "Title", 0, JOptionPane.INFORMATION_MESSAGE, null, options, null);
output is as follows
For more details about the showOptionDialog() function see here.
You might want to checkout JOptionPane.showOptionDialog
, that will let you push in a text parameter (in array form).
Try this one:
See JOptionPane documentation
JOptionPane(Object message, int messageType, int optionType,
Icon icon, Object[] options, Object initialValue)
where options specifies the buttons with initialValue. So you can change them
Example
Object[] options = { "Agree", "Disagree" };
JOptionPane.showOptionDialog(null, "Are you want to continue the process?", "information",
JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE,
null, options, options[0]);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With