📄 queryclassjpanel.java
字号:
/*
* QueryClassJPanel.java
*
* Created on 2007年12月14日, 下午3:21
*/
package 考试成绩分析程序;
import javax.swing.*;
/**
*
* @author drawen
*/
public class QueryClassJPanel extends javax.swing.JPanel {
/** Creates new form QueryClassJPanel */
public QueryClassJPanel() {
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();
jLabel4 = new javax.swing.JLabel();
grade = new javax.swing.JTextField();
major = new javax.swing.JTextField();
classNumber = new javax.swing.JTextField();
confirm = new javax.swing.JButton();
jLabel6 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
text = new javax.swing.JEditorPane();
jLabel1.setText("\u67e5\u8be2\u73ed\u7ea7\u4fe1\u606f");
jLabel2.setText("\u5e74\u7ea7\uff1a");
jLabel3.setText("\u4e13\u4e1a\uff1a");
jLabel4.setText("\u73ed\u53f7\uff1a");
grade.setText("2005");
major.setText("\u8ba1\u7b97\u673a\u79d1\u5b66\u4e0e\u6280\u672f");
classNumber.setText("3");
confirm.setText("\u786e\u5b9a");
confirm.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
confirmButtonActionListener(evt);
}
});
jLabel6.setText("\u73ed\u7ea7\u5b66\u751f\u4fe1\u606f\uff1a");
text.setEditable(false);
jScrollPane1.setViewportView(text);
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.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
.add(layout.createSequentialGroup()
.add(30, 30, 30)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
.add(jLabel2, 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(jLabel4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.add(33, 33, 33)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
.add(layout.createSequentialGroup()
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(grade, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 119, Short.MAX_VALUE))
.add(major)
.add(classNumber))
.add(4, 4, 4))
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(jLabel1)
.add(32, 32, 32)))
.add(layout.createSequentialGroup()
.add(86, 86, 86)
.add(confirm)))
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(89, 89, 89)
.add(jLabel6))
.add(layout.createSequentialGroup()
.add(40, 40, 40)
.add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 212, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
.add(50, 50, 50))
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(19, 19, 19)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel1)
.add(jLabel6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 15, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(17, 17, 17)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel2)
.add(grade, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(26, 26, 26)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel3)
.add(major, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(31, 31, 31)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel4)
.add(classNumber, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(39, 39, 39)
.add(confirm))
.add(layout.createSequentialGroup()
.add(11, 11, 11)
.add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 216, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(39, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
private void confirmButtonActionListener(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_confirmButtonActionListener
int grade,classNumber;
String major;
Class newClass;
try{
grade=Integer.parseInt(this.grade.getText());
classNumber=Integer.parseInt(this.classNumber.getText());
major=this.major.getText();
if((newClass=Class.queryFromFile(grade,major,classNumber))!=null){
JOptionPane.showMessageDialog(null,"查询成功","查询结果",JOptionPane.WARNING_MESSAGE);
String string="年级:"+newClass.getGrade()+"\n专业:"+newClass.getMajor()+"\n班号:"+
newClass.getClassNumber()+"\n学生人数:"+newClass.getStudentNumber()+"\n学生具体信息如下:\n学号\t姓名\n";
Student []student=newClass.getStudents();
for(int i=0;i<newClass.getStudentNumber();i++)
string+=(student[i].getId()+"\t"+student[i].getName()+"\n");
this.text.setText(string);
}
else{
JOptionPane.showMessageDialog(null,"系统中没有此班级的相关信息","查询结果",JOptionPane.WARNING_MESSAGE);
this.text.setText("");
}
}catch(Exception e){
JOptionPane.showMessageDialog(null,"输入的班级信息格式有误","出错",JOptionPane.ERROR_MESSAGE);
this.text.setText("");
}
}//GEN-LAST:event_confirmButtonActionListener
// 变量声明 - 不进行修改//GEN-BEGIN:variables
private javax.swing.JTextField classNumber;
private javax.swing.JButton confirm;
private javax.swing.JTextField grade;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel6;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextField major;
private javax.swing.JEditorPane text;
// 变量声明结束//GEN-END:variables
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -