2011-03-17 111 views
1

你需要添加什么来选择对话框的各种图标?另外你如何使用自定义图标?Java对话框图标

谢谢!

回答

3

你的意思是JDialog s?如果是这样,你正在从Java教程寻找this page。下面复制的是来自该页面的样本,没有截图;看到如何使用自定义图标的最后一个:

//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); 

在这最后一个例子,iconIcon类型的对象。这个版本的showMessageDialog()the Javadoc

+2

接下来你会说火腿不应该变绿。 >:| – Powerlord 2011-03-17 20:18:30

+3

@RBemrose _对消费者的通知:食用绿色鸡蛋和/或火腿可能会增加患上食源性疾病的风险,特别是如果您有某些疾病。请向您的医生或公共卫生官员咨询进一步的信息._ – Pops 2011-03-17 20:23:07