Java 自定义JOptionPane.showInputDialog
如何自定义Java 自定义JOptionPane.showInputDialog,java,swing,joptionpane,Java,Swing,Joptionpane,如何自定义JOptionPane.showInputDialog?例如,我想将Yes和Cancel选项更改为A和B。请记住,它仅适用于showInputDialog查看此答案 在您的情况下,您可以这样做: publicstaticvoidmain(字符串[]args){ 对象[]选项={“A”,“B”}; 对象defaultChoice=choices[0]; JOptionPane.showOptionDialog(null, “选择一个值”, “标题信息”, JOptionPane.YES\
JOptionPane.showInputDialog
?例如,我想将Yes
和Cancel
选项更改为A
和B
。请记住,它仅适用于showInputDialog
查看此答案
在您的情况下,您可以这样做:
publicstaticvoidmain(字符串[]args){
对象[]选项={“A”,“B”};
对象defaultChoice=choices[0];
JOptionPane.showOptionDialog(null,
“选择一个值”,
“标题信息”,
JOptionPane.YES\u NO\u选项,
JOptionPane.QUESTION\u消息,
无效的
选择,
默认选择);
}
如果必须使用showInputDialog
,则可以执行以下操作:
publicstaticvoidmain(字符串[]args){
UIManager.put(“OptionPane.okButtonText”,“A”);
UIManager.put(“OptionPane.cancelButtonText”、“B”);
showInputDialog(“我的对话框”);
UIManager.put(“OptionPane.cancelButtonText”、“Cancel”);
UIManager.put(“OptionPane.okbuttonext”、“OK”);
}
请注意,使用
UIManager
将更改所有输入的值,因此,在对话框后将其更改回非常重要。阅读上的Swing教程,了解如何自定义按钮文本的示例。我知道showOptionDialog,但showInputDialog如何?@hi我已使用showInputDialog