?? stusearchsnum.java
字號:
package Cstudent;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
/**
* 學生信息查詢模塊
* 根據學生的學號查詢學生信息
*/
public class StuSearchSnum extends JFrame implements ActionListener{
Container contentPane;
//框架的大小
Dimension faceSize = new Dimension(300, 100);
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JTextField sFrom = new JTextField(4);
JTextField sTo = new JTextField(4);
JButton searchInfo = new JButton();
public StuSearchSnum() {
//設置標題
this.setTitle("按學號查詢");
this.setResizable(false);
//設置程序圖標
// this.setIconImage(getImage("icon.gif"));
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() throws Exception {
this.setSize(faceSize);
contentPane = this.getContentPane();
contentPane.setLayout(new FlowLayout());
jLabel1.setText("請輸入學號范圍: 從");
jLabel1.setFont(new Font("Dialog",0,12));
contentPane.add(jLabel1);
sFrom.setText(null);
sFrom.setFont(new Font("Dialog",0,12));
contentPane.add(sFrom);
jLabel2.setText(" 到 ");
jLabel2.setFont(new Font("Dialog",0,12));
contentPane.add(jLabel2);
sTo.setText(null);
sTo.setFont(new Font("Dialog",0,12));
contentPane.add(sTo);
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("Sno",sFrom.getText(),sTo.getText());
this.dispose();
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -