📄 confirmwindow.java
字号:
package labraryManager;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class ConfirmWindow extends JFrame implements ActionListener{
public static final int WIDTH=200;
public static final int HEIGHT=100;
public ConfirmWindow(){
setSize(WIDTH,HEIGHT);
addWindowListener(new AnotherWindowDestroyer());
setTitle("图书管理系统");
Container x=getContentPane();
x.setLayout(new BorderLayout());
JLabel z=new JLabel("确定退出?");
x.add(z,BorderLayout.CENTER);
JPanel y=new JPanel();
y.setLayout(new FlowLayout());
JButton b1=new JButton("确定");
b1.addActionListener(this);
y.add(b1);
JButton b2=new JButton("取消");
b2.addActionListener(this);
y.add(b2);
x.add(y,BorderLayout.SOUTH);
}
public void actionPerformed(ActionEvent e){
if(e.getActionCommand().equals("确定"))
System.exit(0);
else if(e.getActionCommand().equals("取消"))
dispose();
else
System.out.println("Error!");
}
private class AnotherWindowDestroyer extends WindowAdapter{
public void windowClosing(WindowEvent e){
dispose();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -