首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

怎么自定义JOptionPane.showInputDialog输入对话框的按钮文本

2012-10-12 
如何自定义JOptionPane.showInputDialog输入对话框的按钮文本我的GUI程序中用到JOptionPane.showInputDial

如何自定义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) 

[解决办法]

探讨
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)


[解决办法]
根据你的要求,只能是自定义对话框了.并且自定义对话框也不是难事.
[解决办法]
你自己写个对话框,照着API的构造函数自定义一下.就是了.
[解决办法]
Java code
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 

热点排行