문제

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top