📄 addstudentjpanel.java
字号:
/*
* AddStudentJPanel.java
*
* Created on 2007年12月13日, 下午7:58
*/
package 考试成绩分析程序;
import javax.swing.*;
/**
*
* @author drawen
*/
public class AddStudentJPanel extends javax.swing.JPanel {
/** Creates new form AddStudentJPanel */
public AddStudentJPanel() {
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();
studentId = new javax.swing.JTextField();
studentName = new javax.swing.JTextField();
confirm = new javax.swing.JButton();
jLabel1.setText("\u589e\u52a0\u5b66\u751f\u4fe1\u606f");
jLabel2.setText("\u5b66\u751f\u5b66\u53f7\uff1a");
jLabel3.setText("\u5b66\u751f\u59d3\u540d\uff1a");
studentId.setText("1");
studentName.setText("\u5c0f\u660e");
confirm.setText("\u786e\u5b9a");
confirm.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
confirmButtonActionListener(evt);
}
});
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)
.add(jLabel2)
.add(jLabel3))
.add(73, 73, 73)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
.add(studentName)
.add(studentId, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 121, Short.MAX_VALUE)))
.add(layout.createSequentialGroup()
.add(156, 156, 156)
.add(confirm))
.add(layout.createSequentialGroup()
.add(143, 143, 143)
.add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 83, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(86, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(43, 43, 43)
.add(jLabel1)
.add(53, 53, 53)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel2)
.add(studentId, 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(studentName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel3))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 50, Short.MAX_VALUE)
.add(confirm)
.add(45, 45, 45))
);
}// </editor-fold>//GEN-END:initComponents
private void confirmButtonActionListener(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_confirmButtonActionListener
try{
long id=Long.parseLong(studentId.getText());
String name=studentName.getText();
Student student=new Student(id,name);
if(student.saveToFile())
JOptionPane.showMessageDialog(null,"增加学生信息成功","结果",JOptionPane.WARNING_MESSAGE);
else
JOptionPane.showMessageDialog(null,"学生信息已经存在或学号重复","结果",JOptionPane.ERROR_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.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JTextField studentId;
private javax.swing.JTextField studentName;
// 变量声明结束//GEN-END:variables
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -