Advertisement
Guest User

Untitled

a guest
Oct 10th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. package passwordmanager;
  2.  
  3. import java.awt.Font;
  4. import java.awt.event.ActionEvent;
  5. import java.awt.event.ActionListener;
  6.  
  7. import javax.swing.*;
  8.  
  9.  
  10. @SuppressWarnings("serial")
  11. public class Frame extends JFrame
  12. {
  13. JLabel username;
  14. JLabel password;
  15. JTextField user;
  16. JPasswordField pass;
  17. JButton login;
  18. public Frame()
  19. {
  20. //Frame
  21. setLayout(null);
  22. setLocationRelativeTo(null);
  23. setResizable(false);
  24. setDefaultCloseOperation(EXIT_ON_CLOSE);
  25. setSize(425, 300);
  26. setVisible(true);
  27. setTitle("Password-Login");
  28.  
  29. //Label 1
  30. username = new JLabel("Benutzernahme:");
  31. username.setBounds(16, 50, 500, 15);
  32.  
  33. //Font
  34. Font font1 = new Font("", Font.BOLD, 13);
  35.  
  36. username.setFont(font1);
  37. add(username);
  38.  
  39. //Label2
  40. password = new JLabel("Passwort:");
  41. password.setBounds(16, 134, 200, 20);
  42. password.setFont(font1);
  43. add(password);
  44.  
  45. //TextField
  46. user = new JTextField();
  47. user.setBounds(16, 76, 350, 30);
  48. user.setVisible(true);
  49. add(user);
  50.  
  51. //PasswordField
  52. pass = new JPasswordField();
  53. pass.setBounds(16, 160, 350, 30);
  54. pass.setVisible(true);
  55. add(pass);
  56.  
  57. //Button
  58. login = new JButton();
  59. login.setBounds(0, 0, 5, 5);
  60. add(login);
  61. }
  62.  
  63. String myusername = user.getText();
  64. String mypassword = new String(pass.getPassword());
  65.  
  66. public class Listener implements ActionListener
  67. {
  68.  
  69. public void actionPerformed(ActionEvent e)
  70. {
  71. if(myusername.equalsIgnoreCase("whatever") && mypassword.equalsIgnoreCase("whatever"))
  72. {
  73. System.out.println("NICE");
  74. }
  75. }
  76. }
  77. }
  78.  
  79. String myusername = user.getText();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement