学生管理系统(JAVA) —— 查找学生信息页面
程序员文章站
2022-06-21 13:55:40
查找页面UI界面如下,2项选择可分别跳转到相应页面:UI界面设计如下:package ui;import java.awt.BorderLayout;import java.awt.Container;import java.awt.Font;import java.awt.GridLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.Butto...
查找页面UI界面如下,2项选择可分别跳转到相应页面:
UI界面设计如下:
package ui;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
public class Search extends JFrame implements ActionListener {
JLabel title;
JRadioButton number,teacher;
JButton dft,rtn;
JPanel sec1,sec2,sec3;
public Search() {
// TODO Auto-generated constructor stub
Container con=getContentPane();
con.setLayout(new BorderLayout());//将容器设置为边框布局
sec1=new JPanel();
sec2=new JPanel();
//边框布局中嵌套一个网格布局,放置两个单选按钮
sec2.setLayout(new GridLayout(1,2));
sec3=new JPanel();
title=new JLabel("学生管理系统");
title.setFont(new Font("黑体", Font.PLAIN, 20));
ButtonGroup bg=new ButtonGroup();
number=new JRadioButton("1.按学号查询",true);
teacher=new JRadioButton("2.按教师姓名查询");
bg.add(number);
bg.add(teacher);
dft=new JButton("确定");
dft.addActionListener(this);
rtn=new JButton("返回");
rtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
setVisible(false);
new Host().setVisible(true);
}
});
sec1.add(title);
sec2.add(number);
sec2.add(teacher);
sec3.add(dft);
sec3.add(rtn);
//将3个面板分别放置在容器的north,center,south位置
con.add(sec1,BorderLayout.NORTH);
con.add(sec2,BorderLayout.CENTER);
con.add(sec3,BorderLayout.SOUTH);
setTitle("查询学生信息");
setSize(300,150);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(number.isSelected()) {
this.setVisible(false);
new SearchByNum().setVisible(true);
}else {
this.setVisible(false);
new SearchByTea().setVisible(true);
}
}
}
本文地址:https://blog.csdn.net/qq_42197887/article/details/107655526