Guest User

Untitled

a guest
Nov 25th, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. import java.awt.event.*;
  2. import javax.swing.*;
  3. import javax.swing.JOptionPane;
  4.  
  5. public class Main extends JFrame implements ActionListener{
  6.  
  7. JLabel unLabel, pwLabel;
  8. JTextField unTextField, pwTextField;
  9. JButton okButton, clearButton, exitButton;
  10. public Main()
  11. {
  12. setLayout(null);
  13. unLabel = new JLabel("Username:");
  14. pwLabel = new JLabel("Password:");
  15.  
  16. unTextField = new JTextField("");
  17. pwTextField = new JTextField("");
  18.  
  19. okButton = new JButton("OK");
  20. clearButton = new JButton("RESET");
  21. exitButton = new JButton("EXIT");
  22.  
  23. unLabel.setBounds(50, 50, 100, 20);
  24. pwLabel.setBounds(50, 80, 100, 20);
  25.  
  26. unTextField.setBounds(150, 50, 100, 20);
  27. pwTextField.setBounds(150, 80, 100, 20);
  28.  
  29. okButton.setBounds(50, 150, 100, 20);
  30. clearButton.setBounds(150, 150, 100, 20);
  31. exitButton.setBounds(250, 150, 100, 20);
  32.  
  33. add(unLabel);
  34. add(pwLabel);
  35. add(unTextField);
  36. add(pwTextField);
  37. add(okButton);
  38. add(clearButton);
  39. add(exitButton);
  40.  
  41. okButton.addActionListener(this);
  42. clearButton.addActionListener(this);
  43. exitButton.addActionListener(this);
  44.  
  45. }
  46.  
  47. public void actionPerformed(ActionEvent event)
  48. {
  49. if (event.getSource()==clearButton)
  50. {
  51. unTextField.setText("");
  52. pwTextField.setText("");
  53. }
  54. else if (event.getSource()==exitButton)
  55. {
  56. System.exit(0);
  57. }
  58. else
  59. {
  60. if((unTextField.getText().equals("adminishi"))&&(pwTextField.getText().equals("123123")))
  61. {
  62. //JOptionPane.showMessageDialog(rootPane, "Congratulation!");
  63. ishi me = new ishi();
  64. me.setSize(500, 300);
  65. me.setVisible(true);
  66.  
  67. {
  68. /* if((unTextField.getText().equals("201010403"))&&(pwTextField.getText().equals("Borbe")))
  69.  
  70. JOptionPane.showMessageDialog(rootPane, "Congratulation!"); */
  71. }
  72. }
  73. }
  74.  
  75. }
  76.  
  77.  
  78.  
  79. public static void main(String[] args)
  80. {
  81.  
  82. Main login = new Main();
  83. login.setSize(500, 300);
  84. login.setVisible(true);
  85.  
  86.  
  87. }
  88. }
Add Comment
Please, Sign In to add comment