Advertisement
Guest User

Untitled

a guest
Apr 10th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.08 KB | None | 0 0
  1. import java.awt.EventQueue;
  2. import java.awt.image.*;
  3. import java.io.File;
  4.  
  5. import javax.swing.JFrame;
  6. import java.awt.GridLayout;
  7. import javax.swing.JTextField;
  8. import javax.swing.JPasswordField;
  9. import javax.swing.JLabel;
  10. import javax.swing.JOptionPane;
  11.  
  12. import java.awt.Font;
  13.  
  14. import javax.imageio.ImageIO;
  15. import javax.swing.ImageIcon;
  16. import javax.swing.JButton;
  17. import javax.swing.SwingConstants;
  18. import java.awt.Color;
  19. import java.awt.event.ActionListener;
  20. import java.awt.event.ActionEvent;
  21.  
  22. public class login {
  23.  
  24. private JFrame frame;
  25. private JTextField username;
  26. private JPasswordField passwordField;
  27. private JLabel lblPassword;
  28. private JLabel globe;
  29. private JLabel lblProjektGlobe;
  30.  
  31. /**
  32. * Launch the application.
  33. */
  34. public static void main(String[] args) {
  35. EventQueue.invokeLater(new Runnable() {
  36. public void run() {
  37. try {
  38. login window = new login();
  39. window.frame.setVisible(true);
  40. } catch (Exception e) {
  41. e.printStackTrace();
  42. }
  43. }
  44. });
  45. }
  46.  
  47. /**
  48. * Create the application.
  49. */
  50. public login() {
  51. initialize();
  52. }
  53.  
  54. /**
  55. * Initialize the contents of the frame.
  56. */
  57. private void initialize() {
  58. frame = new JFrame();
  59. frame.setBounds(100, 100, 450, 300);
  60. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  61. frame.getContentPane().setLayout(null);
  62.  
  63. username = new JTextField();
  64. username.setBounds(169, 111, 140, 20);
  65. frame.getContentPane().add(username);
  66. username.setColumns(10);
  67.  
  68. passwordField = new JPasswordField();
  69. passwordField.setBounds(169, 153, 140, 20);
  70. frame.getContentPane().add(passwordField);
  71.  
  72. JLabel lblUsername = new JLabel("Username");
  73. lblUsername.setFont(new Font("Tahoma", Font.PLAIN, 20));
  74. lblUsername.setBounds(32, 109, 115, 17);
  75. frame.getContentPane().add(lblUsername);
  76.  
  77. lblPassword = new JLabel("Password");
  78. lblPassword.setFont(new Font("Tahoma", Font.PLAIN, 20));
  79. lblPassword.setBounds(32, 149, 101, 20);
  80. frame.getContentPane().add(lblPassword);
  81.  
  82. JButton btnLogin = new JButton("Login");
  83. btnLogin.addActionListener(new ActionListener() {
  84. public void actionPerformed(ActionEvent arg0) {
  85. String user = username.getText();
  86. String psswd = passwordField.getText();
  87.  
  88. if (user.equals("Dustin") && psswd.equals("dustinone"))
  89. {
  90. JOptionPane.showMessageDialog(frame, "Success!");
  91. }
  92. else
  93. {
  94. JOptionPane.showMessageDialog(frame, "Invalid Login!");
  95. }
  96. }
  97. });
  98. btnLogin.setBounds(198, 184, 89, 23);
  99. frame.getContentPane().add(btnLogin);
  100.  
  101. globe = new JLabel("");
  102. globe.setIcon(new ImageIcon(login.class.getResource("/img/earth-icon.png")));
  103. globe.setBounds(345, 11, 79, 81);
  104. frame.getContentPane().add(globe);
  105.  
  106. lblProjektGlobe = new JLabel("Projekt Globe");
  107. lblProjektGlobe.setForeground(new Color(30, 144, 255));
  108. lblProjektGlobe.setFont(new Font("Tahoma", Font.BOLD, 25));
  109. lblProjektGlobe.setHorizontalAlignment(SwingConstants.CENTER);
  110. lblProjektGlobe.setBounds(49, 15, 286, 60);
  111. frame.getContentPane().add(lblProjektGlobe);
  112.  
  113.  
  114.  
  115. }
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement