Change the OK Cancel string in JOptionPane

岁酱吖の 提交于 2019-12-01 16:18:26

Looks like instead of JOptionPane.showConfirmDialog you are going to have to use JOptionPane.showOptionDialog, which lets you supply your own texts as an array.

Try the following:

JOptionPane.showOptionDialog(null, 
        "Do you like this answer?", 
        "Feedback", 
        JOptionPane.OK_CANCEL_OPTION, 
        JOptionPane.INFORMATION_MESSAGE, 
        null, 
        new String[]{"Yes I do", "No I don't"}, // this is the array
        "default");

Look at the javadocs in the detailed class description part:
You aren't limited to this set of option buttons. You can provide any buttons you want using the options parameter.
What (options) is also described there. Anyway the default texts (i.e. OK/Cancel) are usually based on the computer locale, but for custom labels use the method described in the javadocs.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!