📄 querycoursejpanel.java
字号:
/*
* QueryCourseJPanel.java
*
* Created on 2007年12月13日, 下午5:50
*/
package 考试成绩分析程序;
import javax.swing.*;
/**
*
* @author drawen
*/
public class QueryCourseJPanel extends javax.swing.JPanel {
/** Creates new form QueryCourseJPanel */
public QueryCourseJPanel() {
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();
jLabel5 = new javax.swing.JLabel();
inputCourseId = new javax.swing.JTextField();
courseName = new javax.swing.JTextField();
courseCredit = new javax.swing.JTextField();
coursePeriod = new javax.swing.JTextField();
confirm = new javax.swing.JButton();
jLabel6 = new javax.swing.JLabel();
courseId = new javax.swing.JTextField();
jLabel7 = new javax.swing.JLabel();
jLabel1.setText("\u67e5\u8be2\u8bfe\u7a0b\u4fe1\u606f");
jLabel2.setText("\u8f93\u5165\u8bfe\u7a0b\u7f16\u53f7\uff1a");
jLabel3.setText("\u8bfe\u7a0b\u540d\u79f0\uff1a");
jLabel4.setText("\u8bfe\u7a0b\u5b66\u5206\uff1a");
jLabel5.setText("\u8bfe\u7a0b\u5b66\u65f6\uff1a");
inputCourseId.setText("1001");
courseName.setEditable(false);
courseCredit.setEditable(false);
coursePeriod.setEditable(false);
confirm.setText("\u786e\u5b9a");
confirm.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
confirmButtonActionListener(evt);
}
});
jLabel6.setText("\u8bfe\u7a0b\u7f16\u53f7");
courseId.setEditable(false);
jLabel7.setText("\u67e5\u8be2\u7ed3\u679c");
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(60, 60, 60)
.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(layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
.add(org.jdesktop.layout.GroupLayout.LEADING, jLabel5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(org.jdesktop.layout.GroupLayout.LEADING, 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(org.jdesktop.layout.GroupLayout.LEADING, jLabel6, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 60, Short.MAX_VALUE)
.add(org.jdesktop.layout.GroupLayout.LEADING, jLabel7))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(7, 7, 7)
.add(inputCourseId, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 134, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
.add(org.jdesktop.layout.GroupLayout.LEADING, courseId)
.add(org.jdesktop.layout.GroupLayout.LEADING, courseCredit)
.add(org.jdesktop.layout.GroupLayout.LEADING, courseName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 117, Short.MAX_VALUE)
.add(org.jdesktop.layout.GroupLayout.LEADING, coursePeriod)))
.add(26, 26, 26)
.add(confirm)
.add(76, 76, 76))
.add(layout.createSequentialGroup()
.add(124, 124, 124)
.add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 90, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
.addContainerGap(19, Short.MAX_VALUE)
.add(jLabel1)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel2)
.add(inputCourseId, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(confirm))
.add(20, 20, 20)
.add(jLabel7)
.add(17, 17, 17)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel6)
.add(courseId, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(22, 22, 22)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel3)
.add(courseName, 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.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel4)
.add(org.jdesktop.layout.GroupLayout.TRAILING, courseCredit, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(30, 30, 30)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(jLabel5)
.add(coursePeriod, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(31, 31, 31))
);
}// </editor-fold>//GEN-END:initComponents
private void confirmButtonActionListener(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_confirmButtonActionListener
Course course=null;
String id=inputCourseId.getText();
course=Course.queryFromFile(id);
if(course!=null){
courseId.setText(course.getId());
courseName.setText(course.getName());
courseCredit.setText(String.valueOf(course.getCredit()));
coursePeriod.setText(String.valueOf(course.getPeriod()));
JOptionPane.showMessageDialog(null,"查询成功","查询结果",JOptionPane.WARNING_MESSAGE);
}
else{
courseId.setText("");
courseName.setText("");
courseCredit.setText("");
coursePeriod.setText("");
JOptionPane.showMessageDialog(null,"查询不到相应的信息","查询结果",JOptionPane.WARNING_MESSAGE);
}
}//GEN-LAST:event_confirmButtonActionListener
// 变量声明 - 不进行修改//GEN-BEGIN:variables
private javax.swing.JButton confirm;
private javax.swing.JTextField courseCredit;
private javax.swing.JTextField courseId;
private javax.swing.JTextField courseName;
private javax.swing.JTextField coursePeriod;
private javax.swing.JTextField inputCourseId;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
// 变量声明结束//GEN-END:variables
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -