(不是什么程序都能简单DIY;)
//对话框定义;物主:frame;模式:true;
private Dialog about = new Dialog(frame,"关于",true);
private Label info = new Label("Auther:yy-2020",Label.CENTER);
//v0.34;定义"关于"对话框about;v0.33新增;
private void aboutInit() {
about.setSize(100,70);
about.setLocationRelativeTo(frame); //位置跟随;关联frame;
about.setResizable(false); //默认true;
about.add(info,BorderLayout.CENTER); //,"Center";
about.addWindowListener(new MyWinListen()); //注册窗口监听器;MyWinListen;
about.setVisible(true);
}
case "About": aboutInit();break;
对话框about直接关闭即可,只有主窗口(frame)才完全退出;
//v0.33;20221001;退窗口事件响应类;
//exit.addActionListener(e->System.exit(0));
class MyWinListen extends WindowAdapter{
public void windowClosing(WindowEvent e){
e.getWindow().setVisible(false); //关闭窗口;
e.getWindow().dispose(); //释放资源;
if(e.getSource()