更改确定按钮JOptionPane.showConfirmDialog的标题

时间:2016-10-01 09:34:13

标签: java swing

有没有办法在JOptionPane.showConfirmDialog中更改按钮的标题确定,例如我有一个面板,我想在JOptionPane.showConfirmDialog这样的<{1}}内显示

MyPanel pan = new MyPanel();

int result = JOptionPane.showConfirmDialog(null, venteFam, 
        "Title of the panel", JOptionPane.OK_CANCEL_OPTION);

这告诉我这个:

enter image description here

所以我需要的是将确定并取消标题更改为另一个标题,这可能吗?

谢谢。

1 个答案:

答案 0 :(得分:2)

您可以使用JOptionPane.showOptionDialog,它允许您将自己的文本作为数组提供,而不是JOptionPane.showConfirmDialog:

&#13;
&#13;
JOptionPane.showOptionDialog(null, 
        "Do you like this answer?", 
        "Feedback", 
        JOptionPane.OK_CANCEL_OPTION, 
        JOptionPane.INFORMATION_MESSAGE, 
        null, 
        new String[]{"Yes I do", "No I don't"},
        "default");
&#13;
&#13;
&#13;