How to change Yes/No option in confirmation dialog?

Kashama Shinn picture Kashama Shinn · Aug 17, 2013 · Viewed 21.9k times · Source

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

Answer

Aniket Thakur picture Aniket Thakur · Aug 17, 2013

You can do the following

JFrame frame = new JFrame();
String[] options = new String[2];
options[0] = new String("Agree");
options[1] = new String("Disagree");
JOptionPane.showOptionDialog(frame.getContentPane(),"Message!","Title", 0,JOptionPane.INFORMATION_MESSAGE,null,options,null);

output is as follows

enter image description here

For more details about the showOptionDialog() function see here.