开发者

Java Dialog Box Icons

开发者 https://www.devze.com 2023-02-18 00:51 出处:网络
What do you need to add to select various icons for dialog boxes? Also how 开发者_如何学Pythondo you use a custom icon?

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 JDialogs? 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().

0

精彩评论

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

关注公众号