📄 input.java
字号:
/*
* Input.java
*
* Created on 2007年4月14日, 下午9:36
*/
package webmaneger;
/**
*
* @author kk
*/
public class Input extends javax.swing.JFrame {
/** Creates new form Input */
public Input() {
initComponents();
if(MainPanel.flag==1)
{
for(int i=0;i<MainPanel.student[MainPanel.now].size();i++)
{
if(MainPanel.currentID.compareTo(((StudentInfo)(MainPanel.student[MainPanel.now].elementAt(i))).ID)==0)
{
txtName.setText(((StudentInfo)(MainPanel.student[MainPanel.now].elementAt(i))).Name);
txtID.setText(((StudentInfo)(MainPanel.student[MainPanel.now].elementAt(i))).ID);
txtAge.setText(((StudentInfo)(MainPanel.student[MainPanel.now].elementAt(i))).Age);
txtMajor.setText(((StudentInfo)(MainPanel.student[MainPanel.now].elementAt(i))).Major);
txtScore.setText(String.valueOf(((StudentInfo)(MainPanel.student[MainPanel.now].elementAt(i))).Score));
int l=1;
if(((StudentInfo)(MainPanel.student[MainPanel.now].elementAt(i))).Sex.compareTo("男")==0)
l=0;
comSex.setSelectedIndex(l);
k=i;
}
}
}
}
/** 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();
jLabel6 = new javax.swing.JLabel();
txtScore = new javax.swing.JTextField();
txtMajor = new javax.swing.JTextField();
txtAge = new javax.swing.JTextField();
comSex = new javax.swing.JComboBox();
txtID = new javax.swing.JTextField();
txtName = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("\u59d3\u540d");
jLabel2.setText("\u5b66\u53f7");
jLabel3.setText("\u6027\u522b");
jLabel4.setText("\u5e74\u9f84");
jLabel5.setText("\u4e13\u4e1a");
jLabel6.setText("\u603b\u8bc4");
comSex.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "\u7537", "\u5973" }));
jButton1.setText("\u4fdd\u5b58");
jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jButton1MouseClicked(evt);
}
});
jButton2.setText("\u53d6\u6d88");
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(34, 34, 34)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(jButton1)
.add(40, 40, 40)
.add(jButton2))
.add(layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jLabel2)
.add(jLabel1)
.add(jLabel4)
.add(jLabel5)
.add(jLabel3)
.add(jLabel6))
.add(34, 34, 34)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
.add(txtName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 88, Short.MAX_VALUE)
.add(txtID)
.add(txtAge)
.add(txtMajor)
.add(comSex, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 52, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(txtScore))))
.addContainerGap(52, Short.MAX_VALUE))
);
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(txtName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(24, 24, 24)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel2)
.add(txtID, 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(jLabel4)
.add(txtAge, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(16, 16, 16)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel5)
.add(txtMajor, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(24, 24, 24)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel3)
.add(comSex, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(16, 16, 16)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel6)
.add(txtScore, 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(jButton1)
.add(jButton2))
.addContainerGap(57, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton1MouseClicked
// TODO 将在此处添加您的处理代码:
if(MainPanel.flag==1)
{
StudentInfo studentInfo =new StudentInfo();
studentInfo.Name=txtName.getText();
studentInfo.ID=txtID.getText();
studentInfo.Sex=comSex.getSelectedItem().toString();
studentInfo.Age=txtAge.getText();
studentInfo.Major=txtMajor.getText();
studentInfo.Score=Integer.parseInt(txtScore.getText());
MainPanel.student[MainPanel.now].set(k,studentInfo);
this.setVisible(false);
}
if(MainPanel.flag==0)
{
StudentInfo studentInfo =new StudentInfo();
studentInfo.Name=txtName.getText();
studentInfo.ID=txtID.getText();
studentInfo.Sex=comSex.getSelectedItem().toString();
studentInfo.Age=txtAge.getText();
studentInfo.Major=txtMajor.getText();
studentInfo.Score=Integer.parseInt(txtScore.getText());
MainPanel.student[MainPanel.now].add(studentInfo);
this.setVisible(false);
}
}//GEN-LAST:event_jButton1MouseClicked
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Input().setVisible(true);
}
});
}
// 变量声明 - 不进行修改//GEN-BEGIN:variables
private javax.swing.JComboBox comSex;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
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.JTextField txtAge;
private javax.swing.JTextField txtID;
private javax.swing.JTextField txtMajor;
private javax.swing.JTextField txtName;
private javax.swing.JTextField txtScore;
// 变量声明结束//GEN-END:variables
public int k=0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -