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

cxz7531 2008-05-26 12:04:04
我的GUI程序中用到JOptionPane.showInputDialog和JOptionPane.showMessageDialog

现在做多国语言化的时候出现麻烦,这两个对话框的按钮文本时跟随操作系统的,不能自由定义。

我的意图并不是设置按钮的语言类型,而是改变按钮的文本。如果中文操作系统下是"确定" 、“取消”,改成“好”、“关闭”
...全文
1031 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
renq198049 2012-09-27
  • 打赏
  • 举报
回复
dfgsdfg
cxz7531 2008-06-14
  • 打赏
  • 举报
回复
搞清楚了,修改UImanager的属性表
贴出来,大家共享
UIManager.put("OptionPane.titleText", "确认对话框");
UIManager.put("OptionPane.yesButtonText", "好了");
UIManager.put("OptionPane.noButtonText", "不行");
UIManager.put("OptionPane.cancelButtonText", "关闭");
JOptionPane.showConfirmDialog(null, "confirm");
cxz7531 2008-05-28
  • 打赏
  • 举报
回复
定义一个自定义对话框不是难事,但需要自动调整位置大小色调等等,还是很费些时间的
365810247 2008-05-28
  • 打赏
  • 举报
回复


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 Icon
options, // the titles of buttons
options[0]); // default button title

刘彬彬 2008-05-28
  • 打赏
  • 举报
回复
你自己写个对话框,照着API的构造函数自定义一下.就是了.
cpoysy 2008-05-26
  • 打赏
  • 举报
回复
根据你的要求,只能是自定义对话框了.并且自定义对话框也不是难事.
qusic 2008-05-26
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 insiku2 的回复:]
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)

[/Quote]
正解!
API里有说明.
insiku2 2008-05-26
  • 打赏
  • 举报
回复
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)
cxz7531 2008-05-26
  • 打赏
  • 举报
回复
修改原代码很复杂,代价大。而且涉及版权问题
IamHades 2008-05-26
  • 打赏
  • 举报
回复
最好的方式就是去读源代码,然后找到对应的控件,然后做相应修改。

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧