Java普通员工管理系统
2019-05-23 09:56:31来源:博客园 阅读 ()
login GUI界面(登录)
package 普通员工管理系统; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPasswordField; import javax.swing.JTextField; public class Login extends JFrame { /** * */ private static final long serialVersionUID = 1L; private JLabel userlabel =new JLabel("用户名:"); private JLabel passwordlabel = new JLabel("密码:"); private JTextField usertext = new JTextField(); private JPasswordField passwordtext = new JPasswordField(); private JButton but1 = new JButton("确定"); private JButton but2 = new JButton("取消"); public Login() { this.setSize(500, 300); this.setLocation(200, 200); this.setTitle("用户登录"); this.setLayout(null); userlabel.setBounds(120, 20, 50, 30); passwordlabel.setBounds(120, 100, 50, 30); usertext.setBounds(200, 20, 150, 30); passwordtext.setBounds(200, 100, 150, 30); but1.setBounds(150, 150, 80, 30); but2.setBounds(250, 150, 80, 30); this.add(userlabel); this.add(passwordlabel); this.add(usertext); this.add(passwordtext); this.add(but1); this.add(but2); but1.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub String name = usertext.getText(); //获取文本框数据 String password = new String(passwordtext.getPassword()); //获取密码框数据 if("admin".equals(name)&&"123".equals(password)) //判断 { JOptionPane.showMessageDialog(null, "真牛逼,密码对了"); //弹出消息框 } else { JOptionPane.showMessageDialog(null, "用户名或错误"); //弹出消息框 usertext.setText(""); passwordtext.setText(""); } } }); passwordtext.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub String name = usertext.getText(); //获取文本框数据 String password = new String(passwordtext.getPassword()); //获取密码框数据 if("admin".equals(name)&&"123".equals(password)) //判断 { new Home(); JOptionPane.showMessageDialog(null, "真牛逼,密码对了"); //弹出消息框 Login.this.dispose(); } else { JOptionPane.showMessageDialog(null, "用户名或错误"); //弹出消息框 usertext.setText(""); passwordtext.setText(""); } } }); this.setVisible(true); } public static void main(String[] args) { // TODO Auto-generated method stub new Login(); } }
Home GUI界面(主界面)
package 普通员工管理系统; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JFrame; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; public class Home extends JFrame { /** * */ private static final long serialVersionUID = -1131044405944264320L; public Home() { this.setSize(600, 400); this.setLocation(200, 200); this.setTitle("普通员工界面"); //创建菜单栏 JMenuBar mbr = new JMenuBar(); //菜单栏 this.setJMenuBar(mbr); //添加菜单栏到容器 //创建菜单 JMenu men = new JMenu("功能管理"); //菜单 JMenu men1 = new JMenu("系统管理"); mbr.add(men); //添加菜单到菜单栏 mbr.add(men1); //创建菜单项 JMenuItem ltem1 = new JMenuItem("查看个人信息"); //菜单项 JMenuItem ltem2 = new JMenuItem("汇报工作"); JMenuItem ltem3 = new JMenuItem("修改密码"); JMenuItem ltem4 = new JMenuItem("查看测评成绩"); JMenuItem ltem5 = new JMenuItem("登录"); JMenuItem ltem6 = new JMenuItem("问卷"); men.add(ltem1); //添加菜单项到菜单 men.add(ltem2); men.add(ltem3); men.add(ltem4); men1.add(ltem5); men1.add(ltem6); //创建菜单项事件 ltem1.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { // TODO Auto-generated method stub new Information(); //setVisible(false); } }); ltem2.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub new Work(); //setVisible(false); } }); ltem3.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub new Password(); //setVisible(false); } }); ltem4.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub new Achievement(); //setVisible(false); } }); ltem5.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub new Login(); setVisible(false); } }); ltem6.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub //setVisible(false); new Questionnaire(); } }); this.setVisible(true); } public static void main(String[] args) { // TODO Auto-generated method stub new Home(); } }
Information GUI界面(个人信息)
package 普通员工管理系统; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JTextField; public class Information extends JFrame { /** * */ private static final long serialVersionUID = 1L; private JLabel l1 = new JLabel("编号:"); private JLabel l2 = new JLabel("姓名:"); private JLabel l3 = new JLabel("性别:"); private JLabel l4 = new JLabel("级别:"); private JLabel l5 = new JLabel("部门:"); private JLabel l6 = new JLabel("薪资:"); private JTextField t1 = new JTextField("0007"); private JTextField t2 = new JTextField("刘强"); private JTextField t3 = new JTextField("女"); private JTextField t4 = new JTextField("普通用户"); private JTextField t5 = new JTextField("技术部"); private JTextField t6 = new JTextField("4000.0"); public Information() { this.setSize(600, 400); this.setLocation(200, 200); this.setTitle("查看个人信息"); this.setLayout(null); l1.setBounds(100, 20, 50, 30); l2.setBounds(100, 60, 50, 30); l3.setBounds(100, 100, 50, 30); l4.setBounds(100, 140, 50, 30); l5.setBounds(100, 180, 50, 30); l6.setBounds(100, 220, 50, 30); t1.setBounds(200, 25, 250, 20); t2.setBounds(200, 65, 250, 20); t3.setBounds(200, 105, 250, 20); t4.setBounds(200, 145, 250, 20); t5.setBounds(200, 185, 250, 20); t6.setBounds(200, 225, 250, 20); this.add(l1); this.add(l2); this.add(l3); this.add(l4); this.add(l5); this.add(l6); this.add(t1); this.add(t2); this.add(t3); this.add(t4); this.add(t5); this.add(t6); this.setVisible(true); } public static void main(String[] args) { // TODO Auto-generated method stub new Information(); } }
Work GUI界面(汇报工作)
package 普通员工管理系统; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JTextArea; import javax.swing.JTextField; public class Work extends JFrame { /** * */ private static final long serialVersionUID = 1L; private JLabel l1 = new JLabel("汇报人编号:"); private JLabel l2 = new JLabel("汇报内容:"); private JTextField t1 = new JTextField(); private JTextArea tx2 = new JTextArea(50,50); private JButton but1 = new JButton("提交"); public Work() { this.setSize(600, 400); this.setTitle("汇报工作"); this.setLocation(200, 200); this.setLayout(null); l1.setBounds(80, 10, 100, 30); t1.setBounds(180, 10, 150, 30); l2.setBounds(80, 80, 100, 30); tx2.setBounds(180, 80, 250, 150); but1.setBounds(220, 280, 100, 30); this.add(l1); this.add(t1); this.add(l2); this.add(tx2); this.add(but1); but1.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub new Home(); setVisible(false); } }); this.setVisible(true); } public static void main(String[] args) { // TODO Auto-generated method stub new Work(); } }
Password GUI界面(密码重置)
package 普通员工管理系统; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPasswordField; public class Password extends JFrame { /** * */ private static final long serialVersionUID = 1L; private JLabel pslable1 = new JLabel("旧密码:"); private JLabel pslable2 = new JLabel("新密码:"); private JLabel pslable3 = new JLabel("确定密码:"); private JPasswordField psf1 = new JPasswordField(); private JPasswordField psf2 = new JPasswordField(); private JPasswordField psf3 = new JPasswordField(); private JButton but1 = new JButton("修改"); public Password() { this.setSize(600, 400); this.setLocation(200, 200); this.setTitle("重置密码"); this.setLayout(null); pslable1.setBounds(100, 10, 100, 30); pslable2.setBounds(100, 80, 100, 30); pslable3.setBounds(100, 150, 100, 30); psf1.setBounds(200, 10, 150, 30); psf2.setBounds(200, 80, 150, 30); psf3.setBounds(200, 150, 150, 30); but1.setBounds(250, 230, 70,40); this.add(pslable1); this.add(pslable2); this.add(pslable3); this.add(psf1); this.add(psf2); this.add(psf3); this.add(but1); but1.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub setVisible(false); new Login(); } }); this.setVisible(true); } public static void main(String[] args) { // TODO Auto-generated method stub new Password(); } }
Achievement GUI界面(成绩查询)
package 普通员工管理系统; import java.awt.BorderLayout; import javax.swing.*; import javax.swing.JLabel; import javax.swing.JScrollPane; import javax.swing.JTable; public class Achievement extends JFrame { /** * */ private static final long serialVersionUID = 1L; Object[] columnTitle = { "被评测人", "评测经理", "评测成绩" }; Object[][] tableDate = { new Object[] { "0001", "0002", "89.0" }, new Object[] { "0003", "0002", "77.0" }, new Object[] { "0004", "0002", "23.0" } }; private JTable tb1 = new JTable(tableDate, columnTitle); private JLabel lab1 = new JLabel("测评成绩如下:"); private JScrollPane tp1 = new JScrollPane(); public Achievement() { this.setSize(600, 400); this.setTitle("测评成绩"); this.setLocation(200, 200); //this.setLayout(new FlowLayout(FlowLayout.LEFT, 10,10)); this.setLayout(new BorderLayout()); //this.add(new JScrollPane(tb1)); //this.setLayout(null); this.add(lab1,BorderLayout.NORTH); this.add(new JScrollPane(tb1),BorderLayout.CENTER); this.setVisible(true); } public static void main(String[] args) { // TODO Auto-generated method stub new Achievement(); } }
Questionnaire GUI界面(调查问卷)
package 普通员工管理系统; import javax.swing.*; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JRadioButton; public class Questionnaire extends JFrame { /** * */ private static final long serialVersionUID = 1L; //按钮 private JButton bt = new JButton("提交"); //标签 private JLabel l0 = new JLabel("基本情况调查表"); private JLabel l1 = new JLabel("1.喜欢的体育运动:"); private JLabel l2 = new JLabel("2.性别"); private JLabel l3 = new JLabel("3.出生年份:"); private JLabel l4 = new JLabel("4.联系方式:"); private JLabel l5 = new JLabel("5.将您的其他爱好填写到下面区域中:"); //复选框 private JCheckBox cb1 = new JCheckBox("足球"); private JCheckBox cb2 = new JCheckBox("羽毛球"); private JCheckBox cb3 = new JCheckBox("篮球"); //单选框 private JRadioButton rb1 = new JRadioButton("男"); private JRadioButton rb2 = new JRadioButton("女"); //下拉列表 String st[] = {"1978","1979","1976"}; private JComboBox Cob = new JComboBox(st); //文本框 private JTextField tx = new JTextField(); //文本域 private JTextArea tx2 = new JTextArea(50,40); public Questionnaire() { this.setSize(400, 500); this.setLocation(600, 200); this.setTitle("调查问卷"); this.setLayout(null); //标题定位 l0.setBounds(150, 5, 100, 20); //问题1定位 l1.setBounds(0, 20, 150, 20); cb1.setBounds(0, 40, 150, 20); cb2.setBounds(0, 60, 150, 20); cb3.setBounds(0, 80, 150, 20); //问题2定位 l2.setBounds(0, 100, 150, 20); rb1.setBounds(0, 120, 150, 20); rb2.setBounds(0, 140, 150, 20); //问题3定位 l3.setBounds(0, 160, 150, 20); Cob.setBounds(80, 160, 80, 20); //问题4定位 l4.setBounds(0, 200, 150, 20); tx.setBounds(90, 200, 100, 20); //问题5布局 l5.setBounds(0, 240, 300, 20); tx2.setBounds(0, 260, 300,100 ); //按钮布局 bt.setBounds(160, 390,60, 30); this.add(l0); this.add(l1); this.add(cb1); this.add(cb2); this.add(cb3); this.add(l2); this.add(rb1); this.add(rb2); this.add(l3); this.add(Cob); this.add(l4); this.add(tx); this.add(l5); this.add(tx2); this.add(bt); this.setVisible(true); } public static void main(String[] args) { // TODO Auto-generated method stub new Questionnaire(); } }
原文链接:https://www.cnblogs.com/Daixiaobai/p/10911061.html
如有疑问请与原作者联系
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
上一篇:java面向对象练习题
下一篇:消息中间件之ActiveMQ
- 国外程序员整理的Java资源大全(全部是干货) 2020-06-12
- 2020年深圳中国平安各部门Java中级面试真题合集(附答案) 2020-06-11
- 2020年java就业前景 2020-06-11
- 04.Java基础语法 2020-06-11
- Java--反射(框架设计的灵魂)案例 2020-06-11
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash