Advertisement
Guest User

Untitled

a guest
Jul 6th, 2015
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.66 KB | None | 0 0
  1. import java.awt.EventQueue;
  2.  
  3. import javax.swing.JFrame;
  4. import javax.swing.JButton;
  5. import java.awt.BorderLayout;
  6. import javax.swing.JPanel;
  7. import java.awt.event.ActionListener;
  8. import java.awt.event.ActionEvent;
  9. import javax.swing.JLabel;
  10. import java.awt.Color;
  11. import javax.swing.JTextField;
  12. import javax.swing.JTextPane;
  13. import javax.swing.JLayeredPane;
  14.  
  15.  
  16. public class Main {
  17.  
  18. private JFrame frame;
  19. private JTextField textField;
  20. private JTextField textField_1;
  21.  
  22. /**
  23. * Launch the application.
  24. */
  25. public static void main(String[] args) {
  26. EventQueue.invokeLater(new Runnable() {
  27. public void run() {
  28. try {
  29. Main window = new Main();
  30. window.frame.setVisible(true);
  31. } catch (Exception e) {
  32. e.printStackTrace();
  33. }
  34. }
  35. });
  36. }
  37.  
  38. /**
  39. * Create the application.
  40. */
  41. public Main() {
  42. initialize();
  43. }
  44.  
  45. /**
  46. * Initialize the contents of the frame.
  47. */
  48. private void initialize() {
  49. frame = new JFrame();
  50. frame.getContentPane().setForeground(Color.GREEN);
  51. frame.setBounds(100, 100, 612, 389);
  52. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  53. frame.getContentPane().setLayout(null);
  54.  
  55. JLabel lblUserName = new JLabel("User name");
  56. lblUserName.setBackground(Color.YELLOW);
  57. lblUserName.setBounds(158, 70, 67, 25);
  58. frame.getContentPane().add(lblUserName);
  59.  
  60. JLabel lblPassword = new JLabel("Password");
  61. lblPassword.setBounds(158, 146, 53, 14);
  62. frame.getContentPane().add(lblPassword);
  63.  
  64. textField = new JTextField();
  65. textField.setBounds(235, 143, 118, 20);
  66. frame.getContentPane().add(textField);
  67. textField.setColumns(10);
  68.  
  69. textField_1 = new JTextField();
  70. textField_1.setColumns(10);
  71. textField_1.setBounds(235, 72, 118, 20);
  72. frame.getContentPane().add(textField_1);
  73.  
  74. JButton btnLogin = new JButton("Login");
  75. btnLogin.setBounds(151, 228, 256, 61);
  76. frame.getContentPane().add(btnLogin);
  77. btnLogin.addActionListener(new ActionListener() {
  78.  
  79. public void actionPerformed(ActionEvent e)
  80. {
  81. if(textField.equals("Admin"))
  82. {
  83. if(textField.equals("Admin"))
  84. {
  85. JLabel lblLoginSuccessPlease = new JLabel("LOGIN SUCCESS! Please wait while the other functions are loaded");
  86. lblLoginSuccessPlease.setBounds(124, 204, 344, 14);
  87. frame.getContentPane().add(lblLoginSuccessPlease);
  88.  
  89. }
  90. }
  91.  
  92. }
  93. });
  94.  
  95. JLabel lblWelcomeToMy = new JLabel("Welcome to my amazing program!");
  96. lblWelcomeToMy.setBounds(174, 11, 242, 14);
  97. frame.getContentPane().add(lblWelcomeToMy);
  98. }
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement