如何自定义JOptionPane.showInputDialog输入对话框的按钮文本
我的GUI程序中用到JOptionPane.showInputDialog和JOptionPane.showMessageDialog
现在做多国语言化的时候出现麻烦,这两个对话框的按钮文本时跟随操作系统的,不能自由定义。
我的意图并不是设置按钮的语言类型,而是改变按钮的文本。如果中文操作系统下是"确定" 、“取消”,改成“好”、“关闭”
[解决办法]
最好的方式就是去读源代码,然后找到对应的控件,然后做相应修改。
[解决办法]
showInputDialog(Component parentComponent, Object message, String title, int messageType, Icon icon, Object[] selectionValues, Object initialSelectionValue)
showOptionDialog(Component parentComponent, Object message, String title, int optionType, int messageType, Icon icon, Object[] options, Object initialValue)
[解决办法]
Object[] options = { "好", "关闭" };int n = JOptionPane.showOptionDialog(null,"Would you like green eggs and ham?","A Silly Question",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE, null, // do not use a custom Iconoptions, // the titles of buttonsoptions[0]); // default button title