Advertisement
Guest User

Untitled

a guest
May 20th, 2019
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. import java.awt.event.*;
  2. import javax.swing.*;
  3.  
  4. public class LoginScreenGUI extends JFrame implements ActionListener {
  5.  
  6. private String username, password;
  7. private int width, height;
  8. ImagePicture pic;
  9. JLabel lblUsername, lblPassword;
  10. JTextField txtUsername, txtPassword, txtAccountNumber;
  11. JButton btnLogin, btnExit, btnSignUp, btnCreate, btnReturn;
  12.  
  13. public LoginScreenGUI() {
  14. super ("Bank Application");
  15.  
  16. width = 0;
  17. height = 0;
  18.  
  19. setLayout(null);
  20.  
  21. lblUsername = new JLabel ("Enter User Name");
  22. lblPassword = new JLabel ("Enter Password");
  23.  
  24. txtUsername = new JTextField (" ");
  25. txtPassword = new JTextField (" ");
  26.  
  27. btnLogin = new JButton ("Login");
  28. btnExit = new JButton ("Exit");
  29. btnSignUp = new JButton ("Sign Up");
  30.  
  31. setSize (1000, 700);
  32.  
  33. txtUsername.setBounds(450, 300, 100, 40);
  34. txtPassword.setBounds(450, 350, 100, 40);
  35.  
  36. btnLogin.setBounds(150, 500, 80, 40);
  37. btnExit.setBounds(750, 500, 80, 40);
  38. btnSignUp.setBounds(450, 500, 80, 40);
  39.  
  40. add(lblUsername);
  41. add(lblPassword);
  42. add(txtUsername);
  43. add(txtPassword);
  44. add(btnLogin);
  45. add(btnExit);
  46. add(btnSignUp);
  47.  
  48. btnLogin.addActionListener(this);
  49. btnExit.addActionListener(this);
  50. btnSignUp.addActionListener(this);
  51.  
  52. setVisible(true);
  53.  
  54. }
  55.  
  56. public void actionPerformed (ActionEvent e) {
  57. if (e.getSource() == btnSignUp) {
  58. dispose();
  59. JFrame myFrame = new JFrame();
  60. setSize (1000, 700);
  61.  
  62. txtUsername = new JTextField(" ");
  63. txtPassword = new JTextField(" ");
  64.  
  65. btnCreate = new JButton ("Create Account");
  66. btnExit = new JButton ("Exit");
  67. btnReturn = new JButton ("Return To Login");
  68.  
  69. add(txtUsername);
  70. add(txtPassword);
  71. add(txtAccountNumber);
  72. add(btnCreate);
  73. add(btnExit);
  74. add(btnReturn);
  75.  
  76. myFrame.setVisible(true);
  77.  
  78. /* generates new account number everytime the
  79. * create account button is pressed
  80. */
  81.  
  82. public void actionPerformedNested (ActionEvent f) {
  83. if (e.getSource() == btnCreate) {
  84.  
  85. }
  86. if (e.getSource() == btnExit) {
  87. System.exit(0);
  88. }
  89. if (e.getSource() == btnReturn) {
  90. dispose();
  91. LoginScreenGUI.setVisible(true);
  92. }
  93. }
  94.  
  95. }
  96. if (e.getSource() == btnLogin) {
  97. new BalancesGUI();
  98. }
  99. if (e.getSource() == btnExit) {
  100. System.exit(0);
  101. }
  102. }
  103.  
  104. public static void main(String[] args) {
  105. new LoginScreenGUI();
  106.  
  107. }
  108.  
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement