📄 querystudentjpanel.java
字号:
/*
* QueryStudentJPanel.java
*
* Created on 2007年12月13日, 下午8:13
*/
package 考试成绩分析程序;
import javax.swing.*;
/**
*
* @author drawen
*/
public class QueryStudentJPanel extends javax.swing.JPanel {
/** Creates new form QueryStudentJPanel */
public QueryStudentJPanel() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc=" 生成的代码 ">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
inputStudentId = new javax.swing.JTextField();
studentName = new javax.swing.JTextField();
confirm = new javax.swing.JButton();
jLabel4 = new javax.swing.JLabel();
studentId = new javax.swing.JTextField();
jLabel1.setText("\u67e5\u8be2\u5b66\u751f\u4fe1\u606f");
jLabel2.setText("\u8f93\u5165\u5b66\u751f\u5b66\u53f7\uff1a");
jLabel3.setText("\u5b66\u751f\u59d3\u540d\uff1a");
inputStudentId.setText("1");
studentName.setEditable(false);
confirm.setText("\u786e\u5b9a");
confirm.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
confirmButtonActionListener(evt);
}
});
jLabel4.setText("\u5b66\u751f\u5b66\u53f7\uff1a");
studentId.setEditable(false);
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(58, 58, 58)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
.add(jLabel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(jLabel4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(jLabel3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.add(95, 95, 95)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
.add(inputStudentId, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE)
.add(studentId)
.add(studentName)))
.add(layout.createSequentialGroup()
.add(158, 158, 158)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(confirm)
.add(jLabel1))))
.addContainerGap(43, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(40, 40, 40)
.add(jLabel1)
.add(41, 41, 41)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel2)
.add(inputStudentId, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(28, 28, 28)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel4)
.add(studentId, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(15, 15, 15)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel3)
.add(studentName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(31, 31, 31)
.add(confirm)
.addContainerGap(47, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
private void confirmButtonActionListener(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_confirmButtonActionListener
try{
long id=Long.parseLong(inputStudentId.getText());
Student student=Student.queryFromFile(id);
if(student!=null){
studentId.setText(String.valueOf(student.getId()));
studentName.setText(student.getName());
JOptionPane.showMessageDialog(null,"查询学生信息成功","查询结果",JOptionPane.WARNING_MESSAGE);
}
else{
studentId.setText("");
studentName.setText("");
JOptionPane.showMessageDialog(null,"查询不到相应学生信息","查询结果",JOptionPane.WARNING_MESSAGE);
}
}catch(Exception e){
JOptionPane.showMessageDialog(null,"输入数据有误","出错",JOptionPane.ERROR_MESSAGE);
}
}//GEN-LAST:event_confirmButtonActionListener
// 变量声明 - 不进行修改//GEN-BEGIN:variables
private javax.swing.JButton confirm;
private javax.swing.JTextField inputStudentId;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JTextField studentId;
private javax.swing.JTextField studentName;
// 变量声明结束//GEN-END:variables
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -