?? courseinfosearchcnum.java
字號:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
/**
* 課程信息管理模塊
* 根據課程編號查詢課程信息,以供調用者修改或刪除
*/
public class CourseInfoSearchCnum extends JDialog implements ActionListener{
Container contentPane;
String[] s;
//框架的大小
Dimension faceSize = new Dimension(300, 100);
JLabel jLabel1 = new JLabel();
JComboBox selectCnum;
JButton searchInfo = new JButton();
public CourseInfoSearchCnum(JFrame frame) {
super(frame, true);
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() throws Exception {
this.setSize(faceSize);
contentPane = this.getContentPane();
contentPane.setLayout(new FlowLayout());
jLabel1.setText("請輸入或者選擇課程號:");
jLabel1.setFont(new Font("Dialog",0,12));
contentPane.add(jLabel1);
CrsBean getId = new CrsBean();
s = getId.getAllId();
selectCnum = new JComboBox(s);
selectCnum.setSelectedItem(null);
selectCnum.setEditable(true);
selectCnum.setFont(new Font("Dialog",0,12));
contentPane.add(selectCnum);
searchInfo.setText("查詢");
searchInfo.setFont(new Font("Dialog",0,12));
contentPane.add(searchInfo);
selectCnum.addActionListener(this);
searchInfo.addActionListener(this);
}
/**
* 事件處理
*/
public void actionPerformed(ActionEvent e) {
Object obj = e.getSource();
if (obj == selectCnum) { //退出
this.dispose();
}
else if (obj == searchInfo) { //修改
this.dispose();
}
}
/**
* 返回選擇的學號
*/
public String getCnum(){
return (String)this.selectCnum.getSelectedItem();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -