📄 mainwindow.java
字号:
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.sql.*;
public class MainWindow extends JFrame implements ActionListener{
JButton findSt,insertSt,delSt,exitB;
public static void main (String args[]){
MainWindow frame = new MainWindow();
}
/////////////////////////////////////////////
//
public MainWindow(){
Container c=this.getContentPane();
c.setLayout(new GridLayout(1,1));
JPanel lowerPanel=new JPanel();
//
findSt=new JButton("查询");
insertSt =new JButton("添加");
delSt =new JButton("删除");
exitB =new JButton("退出");
//
lowerPanel.add(findSt);
lowerPanel.add(insertSt);
lowerPanel.add(delSt);
lowerPanel.add(exitB);
c.add(lowerPanel);
//
//
findSt.addActionListener(this);
insertSt.addActionListener(this);
delSt.addActionListener(this);
exitB.addActionListener(this);
this.setSize(400,300);
this.setTitle("简易学生管理系统");
this.setLocation(200,200);
this .setVisible(true);
//
this.addWindowListener(new WindowAdapter(){
public void windoeClosing(WindowEvent event){
shutdown();
}
});
}
//////////////////////////////////////////////////////
//
public void actionPerformed(ActionEvent e){
if(e.getSource()==findSt){
findS();
}
if(e.getSource()==insertSt){
insertS();
}
if(e.getSource()==delSt){
delS();
}
if(e.getSource()==exitB){
shutdown();
}
}
private void findS(){
Find find=new Find(this);
find.setVisible(true);
}
private void insertS(){
Insert ins=new Insert(this);
}
private void delS(){
Delete del=new Delete(this);
}
private void shutdown(){
System.exit(0);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -