开发者

Error message icon shown with PLAIN_MESSAGE parameter on a JOptionPane object

I create a dialog using JOptionPane manually using the codes below

JOptionPane pane = new JOptionPane(feedbackPanel, JOptionPane.YES_OPTION, JOptionPane.PLAIN_MESSAGE);
pane.setOptions(options);
pane.setInitialValue(options[0]);
pane.setIcon(null);
JDialog dialog = pane.createDialog(null, "Your feedback");
dialog.setLocation(contentPane.getLocation());
dialog.setVisible(true);

Note that I pass in JOptionPane.PLAIN_MESSAGE when creating the JOptionPane object, however, the dialog still displays a ERROR_MESSAGE icon along with everything else. I would like to get rid of the icon (i.e having no icon at all). Does anyone know where the 开发者_如何学运维problem is? Thanks.


You've got your JOptionPane constructor parameters switched around:

JOptionPane pane = new JOptionPane(feedbackPanel, JOptionPane.PLAIN_MESSAGE, 
    JOptionPane.DEFAULT_OPTION);

It's JOptionPane(message, messageType, optionType)

EDITED:

Also: optionType should be one of {DEFAULT_OPTION, YES_NO_OPTION, YES_NO_CANCEL_OPTION, OK_CANCEL_OPTION}

YES_OPTION is used for the return values.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜