无锡时光科技网站建设公司怎么样,wordpress父主题和子主题,做外汇都看那些网站,小制作小灯笼2019独角兽企业重金招聘Python工程师标准 这是我写的简单代码#xff1a; 简单#xff0c;没什么嚼头#xff0c;作业贴#xff0c;直接上代码。文件保存用户名和密码#xff0c;输入密码错误3次退出程序。 [java] view plaincopy 01.public Login() throws… 2019独角兽企业重金招聘Python工程师标准 这是我写的简单代码 简单没什么嚼头作业贴直接上代码。文件保存用户名和密码输入密码错误3次退出程序。 [java] view plaincopy 01.public Login() throws IOException{ 02. 03. GetKeys();//获取文件登陆信息 04. 05. User new JTextField(15); 06. PassWord new JPasswordField(15); 07. PassWord.setEchoChar(*); 08. 09. JPanel p1 new JPanel(); 10. p1.add(new JLabel(姓名:)); 11. p1.add(User); 12. p1.add(new JLabel(密码:)); 13. p1.add(PassWord); 14. 15. add(p1,BorderLayout.CENTER); 16. JPanel p2 new JPanel(); 17. JButton button new JButton(确定); 18. button.addActionListener(new ActionListener()//登录监听器 19. { 20. SuppressWarnings(deprecation) 21. public void actionPerformed(ActionEvent e) 22. { 23. String name User.getText(); 24. String password PassWord.getText(); 25. if(message.containsKey(name))//姓名正确 26. { 27. num 3;//一个用户名有3次输入密码机会 28. if(message.get(name).equals(password))//密码正确 29. { 30. JOptionPane.showMessageDialog(Login.this, 登陆成功!); 31. System.exit(0); 32. } 33. else 34. { 35. num--; 36. if(num 0) 37. { 38. JOptionPane.showMessageDialog(Login.this, 密码错误!还有num次机会); 39. PassWord.setText(); 40. } 41. else if(num 0) 42. { 43. JOptionPane.showMessageDialog(Login.this, 登录3次失败程序关闭); 44. System.exit(0); 45. } 46. } 47. } 48. else 49. { 50. JOptionPane.showMessageDialog(Login.this, 不存在该用户名); 51. User.setText(); 52. PassWord.setText(); 53. } 54. 55. } 56. }); 57. p2.add(button); 58. 59. button new JButton(取消); 60. button.addActionListener(new ActionListener() 61. { 62. public void actionPerformed(ActionEvent e) 63. { 64. System.exit(0); 65. } 66. }); 67. p2.add(button); 68. 69. add(p2,BorderLayout.SOUTH); 70. setLocation(400,200); 71. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 72. pack(); 73. setVisible(true); 74. } end 转载于:https://my.oschina.net/bigfool007139/blog/399125