对话框按钮未显示在JOptionPane.showConfirmDialog中

时间:2014-01-03 23:40:45

标签: java swing joptionpane jdialog

我的应用程序中有以下对话框。我使用JPanel在对话框中显示以下组件,但我看到确认按钮显示不好。我宁愿用默认对话框解决问题。有可能解决这个问题,或者我需要定义我的对话框。如果我必须定义我的对话框,如何在确认对话框中返回选项值?

enter image description here

我在这种模式下调用showConfirmDialog:

            InterruptionRecoveryPanel irp = 
                    new InterruptionRecoveryPanel(cmo);
            int res = JOptionPane.showConfirmDialog(
                    AppJFrame.this, irp, 
                    "Conferma della operazione interrotta!", 
                    JOptionPane.OK_CANCEL_OPTION);

1 个答案:

答案 0 :(得分:0)

我使用了BoxLayout for InterruptionRecoveryPanel。我在选项文本中添加了一些内容,然后将其3个子面板的AlignmentX设置为LEFT_ALIGNMENT;我只是出于审美原因。以前我想做的事情,我从没想过他们可能与这个问题有关。所以问题解决了。我不知道为什么!这是完全意外的!如果有人能告诉我它为什么会发生,我感激不尽。

enter image description here