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.
精彩评论