Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Common.gui;
- import java.awt.event.ActionEvent;
- import java.io.Serializable;
- import javax.swing.*;
- /**
- *
- * @author tfollansbee
- */
- public class LoginBean extends JPanel implements Serializable{
- private String userName = "";
- private String userPass = "";
- private JTextField uName = new JTextField();
- private JTextField uPass = new JTextField();
- private JLabel nameLabel = new JLabel("User Name:", SwingConstants.RIGHT);
- private JLabel passLabel = new JLabel("Pass Word:", SwingConstants.RIGHT);
- private JButton login = new JButton(new LoginAction("Login", null, "Button to login", 123));
- public LoginBean() {
- initComponents();
- }
- public void initComponents(){
- uName.setMinimumSize(Constants.smallComboSize);
- uName.setPreferredSize(Constants.smallComboSize);
- uName.setMaximumSize(Constants.largeComboSize);
- uPass.setMinimumSize(Constants.smallComboSize);
- uPass.setPreferredSize(Constants.smallComboSize);
- uPass.setMaximumSize(Constants.largeComboSize);
- add(nameLabel);
- add(uName);
- add(passLabel);
- add(uPass);
- add(login);
- }
- public String getUserName() {
- return userName;
- }
- public void setUserName(String userName) {
- this.userName = userName;
- }
- public String getUserPass() {
- return userPass;
- }
- public void setUserPass(String userPass) {
- this.userPass = userPass;
- }
- class LoginAction extends AbstractAction{
- public LoginAction(String text, ImageIcon icon, String desc, Integer mnemonic){
- super(text,icon);
- putValue(SHORT_DESCRIPTION, desc);
- putValue(MNEMONIC_KEY, mnemonic);
- }
- @Override
- public void actionPerformed(ActionEvent ae) {
- String aName;
- String aPass;
- //TODO validation and sanitation
- userName = uName.getText();
- userPass = uPass.getText();
- }
- }
- class LogOutAction extends AbstractAction{
- public LogOutAction(String text, ImageIcon icon, String desc, Integer mnemonic){
- super(text, icon);
- putValue(SHORT_DESCRIPTION, desc);
- putValue(MNEMONIC_KEY, mnemonic);
- }
- @Override
- public void actionPerformed(ActionEvent ae) {
- userName = "";
- userPass = "";
- }
- }
- }
Add Comment
Please, Sign In to add comment