stusearchsname.java

来自「班级管理系统」· Java 代码 · 共 59 行

JAVA
59
字号
package lab.lab;

import javax.swing.*;

import java.awt.*;
import java.awt.event.*;

public class StuSearchSname extends JFrame implements ActionListener {
	Container contentPane;

	Dimension faceSize = new Dimension(300, 100);

	JLabel jLabel1 = new JLabel();

	JTextField sname = new JTextField(8);

	JButton searchInfo = new JButton();

	StuSearchSname() {
		this.setTitle("按姓名查询");
		this.setResizable(false);
		try {
			Init();
		} catch (Exception e) {
			e.printStackTrace();
		}
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		this.setLocation((int) (screenSize.width - 400) / 2,
				(int) (screenSize.height - 300) / 2+45);
	}

	private void Init() {
		this.setSize(faceSize);
		contentPane = this.getContentPane();
		contentPane.setLayout(new FlowLayout());
		jLabel1.setText("请输入学生姓名");
		jLabel1.setFont(new Font("Dialog", 0, 12));
		contentPane.add(jLabel1);
		sname.setText(null);
		sname.setFont(new Font("Dialog", 0, 12));
		contentPane.add(sname);
		searchInfo.setText("确定");
		searchInfo.setFont(new Font("Dialog", 0, 12));
		contentPane.add(searchInfo);
		searchInfo.addActionListener(this);
	}

	public void actionPerformed(ActionEvent e) {
		Object obj = e.getSource();
		if (obj == searchInfo) {
			ResultStudent rS = new ResultStudent("sname", sname.getText());
			rS.pack();
			this.dispose();
		}

	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?