java录入公司职员信息

上传人:xiao****1972 文档编号:84822343 上传时间:2019-03-05 格式:DOC 页数:31 大小:146.50KB
返回 下载 相关 举报
java录入公司职员信息_第1页
第1页 / 共31页
java录入公司职员信息_第2页
第2页 / 共31页
java录入公司职员信息_第3页
第3页 / 共31页
java录入公司职员信息_第4页
第4页 / 共31页
java录入公司职员信息_第5页
第5页 / 共31页
点击查看更多>>
资源描述

《java录入公司职员信息》由会员分享,可在线阅读,更多相关《java录入公司职员信息(31页珍藏版)》请在金锄头文库上搜索。

1、Java程序设计课程设计指导书一、课程设计的目的二、课程设计题目、结构及要求4.设计一个录入和显示公司职员信息的程序界面,成员信息包括ID、姓名、性别、生日、地址和部门等。设计者根据需要选取使用组件。(使用GUI完成)public class Employee implements java.io.Serializable String number,name,discipling,grade,borth,sex; public Employee() public void setNumber(String number) this.number=number; public String g

2、etNumber() return number; public void setName(String name) this.name=name; public String getName() return name; public void setDiscipling(String discipling) this.discipling=discipling; public String getDisciping() return discipling; public void setGrade(String grade) this.grade=grade; public String

3、getGrade() return grade; public void setBorth(String borth) this.borth=borth; public String getBorth() return borth; public void setSex(String sex)this.sex=sex; public String getSex() return sex; 2.import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.io.*;import java.util.Hasht

4、able;public class EmployeeManager extends JFrame implements ActionListener EmployeeSituation 基本信息录入=null; ModifySituation 基本信息修改=null; Inquest 基本信息查询=null; delete 基本信息删除=null; JMenuBar bar; JMenu fileMenu; JMenuItem 录入,修改,查询,删除; Container con=null; Hashtable 基本信息=null; File file=null; CardLayout car

5、d=null; JLabel label=null; JPanel pCenter; public EmployeeManager() 录入=new JMenuItem(录入员工基本信息);修改=new JMenuItem(修改员工基本信息);查询=new JMenuItem(查询员工基本信息);删除=new JMenuItem(删除员工基本信息); bar=new JMenuBar(); fileMenu=new JMenu(菜单选项); fileMenu.add(录入); fileMenu.add(修改); fileMenu.add(查询); fileMenu.add(删除); bar.a

6、dd(fileMenu); setJMenuBar(bar); label=new JLabel(欢迎进入员工信息管理系统,JLabel.CENTER); label.setFont(new Font(SansSerif,Font.BOLD+Font.ITALIC,25); label.setForeground(Color.red); 基本信息=new Hashtable(); 录入.addActionListener(this); 修改.addActionListener(this); 查询.addActionListener(this); 删除.addActionListener(thi

7、s); card=new CardLayout(); con=getContentPane(); pCenter=new JPanel(); pCenter.setLayout(card); pCenter.setBackground(Color.red); file=new File(基本信息.txt); if(!file.exists() try FileOutputStream out=new FileOutputStream(file); ObjectOutputStream objectOut=new ObjectOutputStream(out); objectOut.writeO

8、bject(基本信息); objectOut.close(); out.close(); catch(IOException e) 基本信息录入=new EmployeeSituation(file); 基本信息修改=new ModifySituation(file); 基本信息查询=new Inquest(this,file); 基本信息删除=new delete(file); pCenter.add(欢迎语界面,label); pCenter.add(录入界面,基本信息录入); pCenter.add(修改界面,基本信息修改); pCenter.add(删除界面,基本信息删除); con.

9、add(pCenter,BorderLayout.CENTER); con.validate(); addWindowListener(new WindowAdapter() public void windowClosing(WindowEvent e) System.exit(0);); setVisible(true); setBounds(100,50,420,380); validate(); public void actionPerformed(ActionEvent e) if(e.getSource()=录入) card.show(pCenter,录入界面); else if

10、(e.getSource()=修改) card.show(pCenter,修改界面); else if(e.getSource()=查询) 基本信息查询.setVisible(true); else if(e.getSource()=删除) card.show(pCenter,删除界面); public static void main(String args) new EmployeeManager();3.import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.io.*;import java.u

11、til.*;public class EmployeeSituation extends JPanel implements ActionListener Hashtable 基本信息表=null; JTextField 员工号,姓名,工资; Choice 部门; JRadioButton 男,女; Employee 员工=null; ButtonGroup group=null; JButton 录入,重置; FileInputStream inOne=null; ObjectInputStream inTwo=null; FileOutputStream outOne=null; Obje

12、ctOutputStream outTwo=null; File file=null; public EmployeeSituation(File file) this.file=file; 员工号=new JTextField(10);姓名=new JTextField(10);部门=new Choice();部门.add(请选择);部门.add(研发部);部门.add(销售部);部门.add(人事部);部门.add(安全部);工资=new JTextField(10);group=new ButtonGroup();男=new JRadioButton(男,true);女=new JRad

13、ioButton(女,false);group.add(男);group.add(女);录入=new JButton(录入);重置=new JButton(重置);录入.addActionListener(this);重置.addActionListener(this);Box box1=Box.createHorizontalBox();box1.add(new JLabel(员工号:,JLabel.CENTER);box1.add(员工号);Box box2=Box.createHorizontalBox();box2.add(new JLabel(姓名:,JLabel.CENTER);b

14、ox2.add(姓名);Box box3=Box.createHorizontalBox();box3.add(new JLabel(性别:,JLabel.CENTER);box3.add(男);box3.add(女);Box box4=Box.createHorizontalBox();box4.add(new JLabel(部门:,JLabel.CENTER);box4.add(部门);Box box6=Box.createHorizontalBox();box6.add(new JLabel( ,JLabel.CENTER);Box box5=Box.createHorizontalBox();box5.add(new JLabel(工资:,JLabel.CENTER);box5.add(工资);Box boxH=Box.createVerticalBox();boxH.add(box1);boxH.add(box2);boxH.add(box3);boxH.add(box5);boxH.add(box6);boxH.add(box4);boxH.add(Box.createVerticalGlue();JPanel pCenter=new JPanel();pCenter.add(boxH); pCenter.setBackg

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 大杂烩/其它

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号