我想将YES和NO更改为Like/Disagree。 我该怎么办?如何在确认对话框中更改是/否选项?
int reply = JOptionPane.showConfirmDialog(null,
"Are you want to continue the process?",
"YES?",
JOptionPane.YES_NO_OPTION);
我想将YES和NO更改为Like/Disagree。 我该怎么办?如何在确认对话框中更改是/否选项?
int reply = JOptionPane.showConfirmDialog(null,
"Are you want to continue the process?",
"YES?",
JOptionPane.YES_NO_OPTION);
您可能想要签出JOptionPane.showOptionDialog
,这将允许您推入文本参数(以数组形式)。
试试这个:
JOptionPane(Object message, int messageType, int optionType,
Icon icon, Object[] options, Object initialValue)
其中options指定与初值的按钮。所以,你可以改变它们
例
Object[] options = { "Agree", "Disagree" };
JOptionPane.showOptionDialog(null, "Are you want to continue the process?", "information",
JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE,
null, options, options[0]);
可以使用options
参数推定制选项showOptionDialog;
Object[] options = { "Agree", "Disagree" };
JOptionPane.showOptionDialog(null, "These are my terms", "Terms",
JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null,
options, options[0]);
它工作和更改JOptionPane.showOptionDialog但我想改变为JOptionPane.showConfirmDialog 这是不是也一样? –
试试这个!
int res = JOptionPane.showConfirmDialog(null, "Are you want to continue the process?", "", JOptionPane.YES_NO_OPTION);
switch (res) {
case JOptionPane.YES_OPTION:
JOptionPane.showMessageDialog(null, "Process Successfully");
break;
case JOptionPane.NO_OPTION:
JOptionPane.showMessageDialog(null, "Process is Canceled");
break;
}
[如明明一切都是甲骨文教程](http://docs.oracle.com/javase/tutorial/uiswing/components/dialog.html#button) – mKorbel