📄 stusearchsname.java
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -