java员工管理系统
package 综合大作业01;
import java.io.*;
import java.awt.event.*;
import javax.swing.*;
public class InputArea extends JPanel implements ActionListener{
File f=null;
RandomAccessFile out;
Box baseBox,box1,box2;
String file;
JTextField 员工号,姓名,部门,联系方式;
JButton button;
FileInputStream inOne=null;
ObjectInputStream inTwo=null;
FileOutputStream outOne=null;
ObjectOutputStream outTwo=null;
InputArea(File f){
this.f=f;
员工号=new JTextField(15);
姓名=new JTextField(15);
部门=new JTextField(15);
联系方式=new JTextField(15);
this.button=new JButton("录入");
this.button.addActionListener(this);
box1=Box.createVerticalBox();
box1.add(new JLabel("输入员工号"));
box1.add(Box.createVerticalStrut(10));
box1.add(new JLabel("输入姓名"));
box1.add(Box.createVerticalStrut(10));
box1.add(new JLabel("输入部门"));
box1.add(Box.createVerticalStrut(10));
box1.add(new JLabel("输入联系方式"));
box1.add(Box.createVerticalStrut(10));
box1.add(new JLabel("单机录入"));
box2=Box.createVerticalBox();
box2.add(员工号);
box2.add(Box.createVerticalStrut(10));
box2.add(姓名);
box2.add(Box.createVerticalStrut(10));
box2.add(部门);
box2.add(Box.createVerticalStrut(10));
box2.add(联系方式);
box2.add(Box.createVerticalStrut(10));
box2.add(button);
baseBox=Box.createHorizontalBox();
baseBox.add(box1);
baseBox.add(Box.createHorizontalStrut(12));
baseBox.add(box2);
add(baseBox);
}
public void actionPerformed(ActionEvent e) {
if(e.getSource()==button||e.getSource()==员工号)
{
String number=" ";
number=员工号.getText();
if(number.length()>0)
{
try {
inOne= new FileInputStream(file);
inTwo=new ObjectInputStream(inOne);
inOne.close();
inTwo.close();
}
catch(Exception ee)
{
}
}
}
}
}
运行的时候看看报错的行,有一个变量没有new初始化就用了,比如说f有没有值。也可能是别的,自己调试下看看