orcal java界面_Java登录界面简单设计

1 packagecn.com.view;2

3 importjava.awt.Color;4 importjava.awt.Font;5 importjava.awt.SystemColor;6 importjava.awt.Toolkit;7 importjava.awt.event.ActionEvent;8 importjava.awt.event.MouseEvent;9

10 importjavax.swing.ImageIcon;11 importjavax.swing.JButton;12 importjavax.swing.JFrame;13 importjavax.swing.JLabel;14 importjavax.swing.JOptionPane;15 importjavax.swing.JPanel;16 importjavax.swing.JPasswordField;17 importjavax.swing.JProgressBar;18 importjavax.swing.JTextField;19

20 importsun.awt.HorizBagLayout;21

22

23 importcn.com.beans.UserInfoBean;24 importcn.com.beans.UserInfoViewBean;25 importcn.com.daos.UserInfoDAO;26 importcn.com.listeners.LoginFrame_btnLogin_ActionListener;27 importcn.com.listeners.LoginFrame_btnReset_ActionListener;28 importcn.com.listeners.LoginFrame_lblRegist_MouseListener;29

30

31 public class LoginFrame extendsJFrame {32 JPanel pnlMain;33 JButton btnLogin;34 JButton btnReset;35 JLabel lblUserName;36 JLabel lblUserPwd;37 JLabel lblTitle;38 JLabel lblRegist;39 JTextField txtUserName;40 JPasswordField pwdUserPwd;41 JProgressBar progressBar;42 JLabel lblLoginStat;43

44 publicLoginFrame() {45 pnlMain = new JPanel(null);46 btnLogin = new JButton("登录");47 btnReset = new JButton("重置");48 lblUserName = new JLabel("用户名:");49 lblUserPwd = new JLabel("密 码:");50 lblTitle = new JLabel("用户登录");51 lblRegist = new JLabel("注册");52 txtUserName = newJTextField();53 pwdUserPwd = newJPasswordField();54 progressBar = newJProgressBar();55 progressBar.setIndeterminate(false);56 progressBar.setOrientation(JProgressBar.HORIZONTAL);57 progressBar.setForeground(new Color(0, 255, 0));58 progressBar.setBounds(286, 348, 146, 14);59 init();60 }61

62 private voidinit() {63 //TODO Auto-generated method stub

64 this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);65 setIconImage(Toolkit.getDefaultToolkit().getImage("image\\e.jpg"));66 this.setBounds(100, 100, 559, 351);67 this.setLocationRelativeTo(null);68 this.setResizable(false);69 this.getContentPane().setLayout(null);70 getContentPane().setBackground(new Color(255, 255, 255));71

72

73 JLabel label = new JLabel("人事管理系统用户登录");74 label.setFont(new Font("楷体", Font.PLAIN, 40));75 label.setBackground(Color.WHITE);76 label.setBounds(79, 10, 400, 43);77 this.getContentPane().add(label);78

79 JLabel lblNewLabel = new JLabel("图片");80 lblNewLabel.setBounds(10, 63, 250, 250);81 this.getContentPane().add(lblNewLabel);82 lblNewLabel.setIcon(new ImageIcon("D:\\Workspaces\\PMSys\\image\\login.jpg"));83

84 JLabel lblUserName = new JLabel("用户名:");85 lblUserName.setFont(new Font("华文楷体", Font.BOLD, 15));86 lblUserName.setBounds(270, 100, 65, 28);87 this.getContentPane().add(lblUserName);88

89 JLabel lblUserPwd = new JLabel("密 码:");90 lblUserPwd.setFont(new Font("华文楷体", Font.BOLD, 15));91 lblUserPwd.setBounds(270, 163, 65, 25);92 this.getContentPane().add(lblUserPwd);93

94 txtUserName = newJTextField();95 txtUserName.setText("请输入用户名");96 txtUserName.setBounds(345, 97, 173, 31);97 txtUserName.setBackground(new Color(255, 255, 204));98 this.getContentPane().add(txtUserName);99 txtUserName.setColumns(10);100

101 pwdUserPwd = newJPasswordField();102 pwdUserPwd.setFont(new Font("宋体", Font.BOLD, 20));103 pwdUserPwd.setBounds(345, 160, 173, 28);104 pwdUserPwd.setBackground(new Color(255, 255, 204));105 this.getContentPane().add(pwdUserPwd);106

107 JButton btnLogin = new JButton("登录");108

109 btnLogin.setBounds(272, 217, 93, 43);110 this.getContentPane().add(btnLogin);111

112 JButton btnReset = new JButton("重置");113

114 btnReset.setBounds(427, 217, 93, 43);115 this.getContentPane().add(btnReset);116

117 lblLoginStat = new JLabel("登录中>>>>");118 lblLoginStat.setForeground(Color.RED);119 lblLoginStat.setFont(new Font("华文楷体", Font.BOLD, 15));120 lblLoginStat.setBounds(270,270,246,14);121 this.getContentPane().add(lblLoginStat);122 lblLoginStat.setVisible(false);123

124 progressBar.setBounds(272,284,246,14);125 progressBar.setIndeterminate(true);126 progressBar.setVisible(false);127 this.getContentPane().add(progressBar);128 this.setVisible(true);129

130 //添加监听事件

131 btnLogin.addActionListener(new LoginFrame_btnLogin_ActionListener(this));132 btnReset.addActionListener(new LoginFrame_btnReset_ActionListener(this));133 lblRegist.addMouseListener(new LoginFrame_lblRegist_MouseListener(this));134 }135

136 public voidbtnLogin_actionPerformed(ActionEvent e){137 //TODO Auto-generated method stub

138

139 progressBar.setVisible(true);140 lblLoginStat.setVisible(true);141 UserInfoDAO dao = newUserInfoDAO();142 String userName = this.txtUserName.getText();143 String userPwd = new String(this.pwdUserPwd.getPassword());144 if(dao.validateByNameAndPwd(userName, userPwd)) {145 UserInfoViewBean ab =dao.getUserListInfoByUserName(userName);146 newMainFrame(ab);147 this.dispose();148 }else{149 //JOptionPane.showMessageDialog(null, "用户名或密码错误","错误",JOptionPane.ERROR_MESSAGE);

150 int n = JOptionPane.showConfirmDialog(null, "密码错误,是否重新登录?", "提示",JOptionPane.YES_NO_OPTION);151 if(n == 0){152 //progressBar.setIndeterminate(false);

153 progressBar.setVisible(false);154 lblLoginStat.setVisible(false);155 }else{156 System.exit(0);157 }158

159 }160 }161 //重置监听事件

162 public voidbtnReset_actionPerformed(ActionEvent e) {163 //TODO Auto-generated method stub

164 this.txtUserName.setText("");165 this.pwdUserPwd.setText("");166 }167

168 public voidlblRegist_mouseClicked(MouseEvent e) {169 }170

171 }

1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 、4下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合;、下载 4使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合;、 4下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。
1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.m或d论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 、1资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。
1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。、资源 5来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。、资 5源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值