?? stuqueryname.java~6~
字號(hào):
package stumng;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
public class stuQueryName extends JFrame {
DBConnManager dbconnmanager = new DBConnManager();
BorderLayout borderLayout1 = new BorderLayout();
JPanel jPanel1 = new JPanel();
JLabel jLabel1 = new JLabel();
JTextField jTextField1 = new JTextField();
JScrollPane jScrollPane1 = new JScrollPane();
JTable jTable1 = new JTable();
JComboBox jComboBox1 = new JComboBox();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
private String aclass;
private String aname;
public stuQueryName() {
try {
jbInit();
//設(shè)置frame的大小
this.setSize(600, 400);
//得到當(dāng)前屏幕大小
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
//得到frame的大小
Dimension frameSize = this.getSize();
if (frameSize.height > screenSize.height) {
frameSize.height = screenSize.height;
}
if (frameSize.width > screenSize.width) {
frameSize.width = screenSize.width;
}
this.setTitle("查詢學(xué)生信息");
//設(shè)置frame在屏幕上顯示的位置
this.setLocation( (screenSize.width - frameSize.width) / 2,
(screenSize.height - frameSize.height) / 2);
}
catch(Exception ex) {
ex.printStackTrace();
}
//按學(xué)號(hào)查詢?cè)搶W(xué)生的基本信息
jButton1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
Vector result = new Vector();
Vector resultdate = new Vector();
Vector headline = new Vector();
headline.add("stu_id");
headline.add("name");
headline.add("class");
headline.add("sex");
headline.add("birthday");
headline.add("ethnic");
headline.add("nativeplace");
aname = jTextField1.getText();
if (aname.equals("")) JOptionPane.showMessageDialog(null, "請(qǐng)輸入姓名");
else{
aclass = (String) jComboBox1.getSelectedItem();
result = dbconnmanager.stuinfQuery(0, aclass, aname);
if (result == null) JOptionPane.showMessageDialog(null, "無記錄");
else {
for (int i = 0; i < result.size() / 7; i++) {
Vector temp = new Vector();
for (int j = 0; j <= 6; j++) {
String str = (String) result.elementAt(j + i * 7);
temp.add(str);
}
resultdate.add(temp);
}
jTable1 = new JTable(resultdate, headline);
jTable1.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); //滾動(dòng)條設(shè)置左右滾
jScrollPane1.getViewport().add(jTable1, null); //在滾動(dòng)條中放入表
}
}
}
});
//退出frame
jButton2.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
jButton2_actionPerformed(e);
}
});
}
void jbInit() throws Exception {
this.getContentPane().setLayout(borderLayout1);
jLabel1.setFont(new java.awt.Font("Dialog", 0, 13));
jLabel1.setText("請(qǐng)輸入姓名");
jTextField1.setOpaque(false);
jTextField1.setPreferredSize(new Dimension(100, 21));
jTextField1.setSelectionStart(21);
jTextField1.setText("");
jButton1.setFont(new java.awt.Font("Dialog", 0, 13));
jButton1.setText("提交");
jButton2.setFont(new java.awt.Font("Dialog", 0, 13));
jButton2.setText("退出");
jComboBox1.setFont(new java.awt.Font("Dialog", 0, 13));
jComboBox1.addItem("A2241");
jComboBox1.addItem("A2242");
jComboBox1.addItem("A2243");
jComboBox1.addItem("全校");
this.getContentPane().add(jPanel1, BorderLayout.NORTH);
jPanel1.add(jLabel1, null);
jPanel1.add(jTextField1, null);
jPanel1.add(jComboBox1, null);
jPanel1.add(jButton1, null);
jPanel1.add(jButton2, null);
this.getContentPane().add(jScrollPane1, BorderLayout.CENTER);
}
void jButton2_actionPerformed(ActionEvent e)
{
this.dispose();
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -