What do you need to add to select various icons for dialog boxes? Also how 开发者_如何学Pythondo you use a custom icon?
Thanks!
Do you mean JDialog
s? If so, you're looking for this page from the Java Tutorials. Copied below are the samples from that page, without the screenshots; see the last one for how to use a custom icon:
//default title and icon
JOptionPane.showMessageDialog(frame,
"Eggs are not supposed to be green.",
"Message");
//custom title, warning icon
JOptionPane.showMessageDialog(frame,
"Eggs are not supposed to be green.",
"Inane warning",
JOptionPane.WARNING_MESSAGE);
//custom title, error icon
JOptionPane.showMessageDialog(frame,
"Eggs are not supposed to be green.",
"Inane error",
JOptionPane.ERROR_MESSAGE);
//custom title, no icon
JOptionPane.showMessageDialog(frame,
"Eggs are not supposed to be green.",
"A plain message",
JOptionPane.PLAIN_MESSAGE);
//custom title, custom icon
JOptionPane.showMessageDialog(frame,
"Eggs are not supposed to be green.",
"Inane custom dialog",
JOptionPane.INFORMATION_MESSAGE, icon);
In that last example, icon
is an object of type Icon
. Here's the Javadoc for that version of showMessageDialog()
.
精彩评论