您好,欢迎访问三七文档
importjava.awt.BorderLayout;importjava.awt.Color;importjava.awt.FlowLayout;importjava.awt.GridLayout;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjava.awt.event.WindowAdapter;importjava.awt.event.WindowEvent;importjavax.swing.JButton;importjavax.swing.JComboBox;importjavax.swing.JFrame;importjavax.swing.JLabel;importjavax.swing.JPanel;importjavax.swing.JTextField;publicclassAddEmployeeFrameextendsJFrameimplementsActionListener{JPanelbianhaopnl=newJPanel();JPanelgangweipnl=newJPanel();JPanelxingshipnl=newJPanel();JPanelmingzipnl=newJPanel();JPaneladdresspnl=newJPanel();JPaneltelephonepnl=newJPanel();JPanelbuttnpnl=newJPanel();JLabelbianhaolbl=newJLabel(员工编号:);JTextFieldbianhaotxt=newJTextField(30);JLabelgangweilbl=newJLabel(工作岗位:);JComboBoxgangwei=newJComboBox();JLabelxingshilbl=newJLabel(员工姓氏:);JTextFieldxingshitxt=newJTextField(30);JLabelmingzilbl=newJLabel(员工名字:);JTextFieldmingzitxt=newJTextField(30);JLabeladdresslbl=newJLabel(通讯地址:);JTextFieldaddresstxt=newJTextField(30);JLabeltelephonelbl=newJLabel(联系电话:);JTextFieldtelephonetxt=newJTextField(30);JButtonaddbtn=newJButton(添加);JButtondelbtn=newJButton(撤销);JButtonexitbtn=newJButton(退出);publicAddEmployeeFrame(){super(添加-雇员);this.setResizable(false);setLayout(newGridLayout(7,1));gangweipnl.setLayout(newFlowLayout(FlowLayout.LEFT));this.addWindowListener(newWindowAdapter(){publicvoidwindowClosing(WindowEvente){System.exit(0);}});gangwei.addItem(老板);gangwei.addItem(员工);gangwei.addItem(经理);bianhaopnl.add(bianhaolbl);bianhaopnl.add(bianhaotxt);gangweipnl.add(gangweilbl);gangweipnl.add(gangwei);xingshipnl.add(xingshilbl);xingshipnl.add(xingshitxt);mingzipnl.add(mingzilbl);mingzipnl.add(mingzitxt);addresspnl.add(addresslbl);addresspnl.add(addresstxt);telephonepnl.add(telephonelbl);telephonepnl.add(telephonetxt);buttnpnl.add(addbtn);buttnpnl.add(delbtn);buttnpnl.add(exitbtn);add(bianhaopnl);add(gangweipnl);add(xingshipnl);add(mingzipnl);add(addresspnl);add(telephonepnl);add(buttnpnl);this.setLocation(400,200);bianhaopnl.setBackground(Color.WHITE);gangweipnl.setBackground(Color.WHITE);xingshipnl.setBackground(Color.WHITE);mingzipnl.setBackground(Color.WHITE);addresspnl.setBackground(Color.WHITE);telephonepnl.setBackground(Color.WHITE);buttnpnl.setBackground(Color.WHITE);this.addWindowListener(newWindowAdapter(){publicvoidwindowClosing(WindowEvente){System.exit(0);}});this.pack();setVisible(true);}publicstaticvoidmain(String[]args){newAddEmployeeFrame();}publicvoidactionPerformed(ActionEventarg0){//TODOAuto-generatedmethodstub}}importjava.awt.Color;importjava.awt.FlowLayout;importjava.awt.GridLayout;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjava.awt.event.WindowAdapter;importjava.awt.event.WindowEvent;importjavax.swing.JButton;importjavax.swing.JComboBox;importjavax.swing.JFrame;importjavax.swing.JLabel;importjavax.swing.JOptionPane;importjavax.swing.JPanel;importjavax.swing.JScrollPane;importjavax.swing.JTable;importjavax.swing.JTextField;importjavax.swing.event.ChangeEvent;importjavax.swing.event.ListSelectionEvent;importjavax.swing.event.TableColumnModelEvent;importjavax.swing.event.TableColumnModelListener;importjavax.swing.event.TableModelEvent;importjavax.swing.event.TableModelListener;importjavax.swing.table.DefaultTableModel;importjavax.swing.table.TableModel;publicclassEditEmployeeFrameextendsJFrameimplementsActionListener,TableModelListener{JPanelbianhaopnl=newJPanel();JPanelgangweipnl=newJPanel();JPanelxingshipnl=newJPanel();JPanelmingzipnl=newJPanel();JPaneladdresspnl=newJPanel();JPaneltelephonepnl=newJPanel();JPanelbuttnpnl=newJPanel();JLabelbianhaolbl=newJLabel(员工编号:);JTextFieldbianhaotxt=newJTextField(30);JLabelgangweilbl=newJLabel(工作岗位:);JComboBoxgangwei=newJComboBox();JLabelxingshilbl=newJLabel(员工姓氏:);JTextFieldxingshitxt=newJTextField(30);JLabelmingzilbl=newJLabel(员工名字:);JTextFieldmingzitxt=newJTextField(30);JLabeladdresslbl=newJLabel(通讯地址:);JTextFieldaddresstxt=newJTextField(30);JLabeltelephonelbl=newJLabel(联系电话:);JTextFieldtelephonetxt=newJTextField(30);JButtonsearchbtn=newJButton(查找);JButtondelbtn=newJButton(删除);JButtonexitbtn=newJButton(退出);publicEditEmployeeFrame(){super(编辑--雇员);this.setResizable(false);setLayout(newGridLayout(7,1));gangweipnl.setLayout(newFlowLayout(FlowLayout.LEFT));this.addWindowListener(newWindowAdapter(){publicvoidwindowClosing(WindowEvente){System.exit(0);}});gangwei.addItem(老板);gangwei.addItem(员工);gangwei.addItem(经理);bianhaopnl.add(bianhaolbl);bianhaopnl.add(bianhaotxt);gangweipnl.add(gangweilbl);gangweipnl.add(gangwei);xingshipnl.add(xingshilbl);xingshipnl.add(xingshitxt);mingzipnl.add(mingzilbl);mingzipnl.add(mingzitxt);addresspnl.add(addresslbl);addresspnl.add(addresstxt);telephonepnl.add(telephonelbl);telephonepnl.add(telephonetxt);buttnpnl.add(searchbtn);buttnpnl.add(delbtn);buttnpnl.add(exitbtn);add(bianhaopnl);add(gangweipnl);add(xingshipnl);add(mingzipnl);add(addresspnl);add(telephonepnl);add(buttnpnl);this.setLocation(400,200);bianhaopnl.setBackground
本文标题:Swing项目
链接地址:https://www.777doc.com/doc-756411 .html