java - Custom JOptionPane Icon -
java's "how make dialogs" tutorial shows code:
//custom title, custom icon joptionpane.showmessagedialog(frame, "eggs not supposed green.", "inane custom dialog", joptionpane.information_message, icon);
which create following dialog:
why joptionpane.information_message
needed when icon changed icon
parameter?
the flag indicates message style use on window decorations, see http://nadeausoftware.com/node/91#usinglookandfeelspecificwindowdecorations
from joptionpane class source code:
private static int stylefrommessagetype(int messagetype) { switch (messagetype) { case error_message: return jrootpane.error_dialog; case question_message: return jrootpane.question_dialog; case warning_message: return jrootpane.warning_dialog; case information_message: return jrootpane.information_dialog; case plain_message: default: return jrootpane.plain_dialog; } }
and in method showoptiondialog called showmessagedialog...
int style = stylefrommessagetype(messagetype); jdialog dialog = pane.createdialog(parentcomponent, title, style);
Comments
Post a Comment