引用头文件:
import javax.swing.JOptionPane;
设置提示框的字体
// 设置按钮显示效果
UIManager.put("OptionPane.buttonFont", new FontUIResource(new Font("微软雅黑", Font.PLAIN, 18)));
// 设置文本显示效果
UIManager.put("OptionPane.messageFont", new FontUIResource(new Font("微软雅黑", Font.PLAIN, 16)));
showMessageDialog提示样式:
JOptionPane.showMessageDialog(null, "文字", "标题", JOptionPane.INFORMATION_MESSAGE);
showMessageDialog错误样式:
JOptionPane.showMessageDialog(null, "文字", "标题", JOptionPane.ERROR_MESSAGE);
showMessageDialog问号样式:
JOptionPane.showMessageDialog(null, "文字", "标题", JOptionPane.QUESTION_MESSAGE);
showMessageDialog普通样式:
JOptionPane.showMessageDialog(null, "文字", "标题", JOptionPane.PLAIN_MESSAGE);
单击button弹出确认框:
public void actionPerformed(ActionEvent e) {
if(JOptionPane.showConfirmDialog(Test.this, "确定关闭吗?","确认",JOptionPane.OK_CANCEL_OPTION)==0)
System.exit(0);}
});
原文
https://blog.csdn.net/u011449331/article/details/21469237?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase