2011-03-17 47 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