您需要添加什么来选择对话框的各种图标?另外你如何使用自定义图标?
谢谢!
答案 0 :(得分:3)
你的意思是JDialog
?如果是这样,您正在从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);
在最后一个示例中,icon
是Icon
类型的对象。这个showMessageDialog()
版本的the Javadoc。