Guest User

Untitled

a guest
Oct 8th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. package Common.gui;
  2.  
  3. import java.awt.event.ActionEvent;
  4. import java.io.Serializable;
  5. import javax.swing.*;
  6.  
  7. /**
  8. *
  9. * @author tfollansbee
  10. */
  11. public class LoginBean extends JPanel implements Serializable{
  12. private String userName = "";
  13. private String userPass = "";
  14. private JTextField uName = new JTextField();
  15. private JTextField uPass = new JTextField();
  16. private JLabel nameLabel = new JLabel("User Name:", SwingConstants.RIGHT);
  17. private JLabel passLabel = new JLabel("Pass Word:", SwingConstants.RIGHT);
  18. private JButton login = new JButton(new LoginAction("Login", null, "Button to login", 123));
  19.  
  20. public LoginBean() {
  21. initComponents();
  22. }
  23.  
  24. public void initComponents(){
  25. uName.setMinimumSize(Constants.smallComboSize);
  26. uName.setPreferredSize(Constants.smallComboSize);
  27. uName.setMaximumSize(Constants.largeComboSize);
  28.  
  29. uPass.setMinimumSize(Constants.smallComboSize);
  30. uPass.setPreferredSize(Constants.smallComboSize);
  31. uPass.setMaximumSize(Constants.largeComboSize);
  32.  
  33. add(nameLabel);
  34. add(uName);
  35. add(passLabel);
  36. add(uPass);
  37. add(login);
  38. }
  39.  
  40. public String getUserName() {
  41. return userName;
  42. }
  43.  
  44. public void setUserName(String userName) {
  45. this.userName = userName;
  46. }
  47.  
  48. public String getUserPass() {
  49. return userPass;
  50. }
  51.  
  52. public void setUserPass(String userPass) {
  53. this.userPass = userPass;
  54. }
  55.  
  56. class LoginAction extends AbstractAction{
  57. public LoginAction(String text, ImageIcon icon, String desc, Integer mnemonic){
  58. super(text,icon);
  59. putValue(SHORT_DESCRIPTION, desc);
  60. putValue(MNEMONIC_KEY, mnemonic);
  61. }
  62. @Override
  63. public void actionPerformed(ActionEvent ae) {
  64. String aName;
  65. String aPass;
  66. //TODO validation and sanitation
  67. userName = uName.getText();
  68. userPass = uPass.getText();
  69. }
  70. }
  71.  
  72. class LogOutAction extends AbstractAction{
  73. public LogOutAction(String text, ImageIcon icon, String desc, Integer mnemonic){
  74. super(text, icon);
  75. putValue(SHORT_DESCRIPTION, desc);
  76. putValue(MNEMONIC_KEY, mnemonic);
  77. }
  78. @Override
  79. public void actionPerformed(ActionEvent ae) {
  80. userName = "";
  81. userPass = "";
  82. }
  83. }
  84. }
Add Comment
Please, Sign In to add comment