RRRRHHHH_Code
4f8bcc7fa6ac7640915ac3aa5e115b6d37c08a86
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
package gui; import java.awt.Color; import java.awt.Frame; import java.awt.KeyEventDispatcher; import java.awt.KeyboardFocusManager; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.rmi.Naming; import java.rmi.RemoteException; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JPasswordField; import javax.swing.JTextField; import javax.swing.SwingConstants; import common.LoginInterface; import configuration.___IntNames; import domain.Account; public class LoginGUI extends JFrame { private static final long serialVersionUID= 1L; private JPanel jContentPane = null; private JTextField usernameField; private JPasswordField passwordField; private LoginInterface loginManager = null; private JLabel loginFeedback; private JButton btnRegister; protected boolean isFocused = false; public LoginGUI() { super(); initialize(); } private void initialize() { try { loginManager = (LoginInterface) Naming .lookup(___IntNames.LoginManager); } catch (Exception e1) { System.out.println("Error accessing remote authentication: " + e1.toString()); } this.setSize(449, 293); this.setContentPane(getJContentPane()); this.setTitle("Login"); addWindowListener(new WindowAdapter() { @Override public void windowGainedFocus(WindowEvent e) { isFocused = true; } @Override public void windowLostFocus(WindowEvent e) { isFocused = false; } }); KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(new KeyEventDispatcher() { @Override public boolean dispatchKeyEvent(KeyEvent e) { if (isFocused && e.getKeyCode() == KeyEvent.VK_ENTER ) jButton_ActionPerformed(); return false; }}); } private JPanel getJContentPane() { if (jContentPane == null) { jContentPane = new JPanel(); jContentPane.setLayout(null); JLabel usernameTag = new JLabel("Username:"); usernameTag.setBounds(56, 67, 104, 20); jContentPane.add(usernameTag); JLabel passwordTag = new JLabel("Password:"); passwordTag.setBounds(56, 132, 104, 15); jContentPane.add(passwordTag); usernameField = new JTextField(); usernameField.setBounds(202, 65, 133, 25); jContentPane.add(usernameField); usernameField.setColumns(10); passwordField = new JPasswordField(); passwordField.setBounds(202, 122, 133, 25); jContentPane.add(passwordField); JButton loginButton = new JButton("Login"); loginButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { jButton_ActionPerformed(); } }); loginButton.setBounds(95, 179, 117, 25); jContentPane.add(loginButton); loginFeedback = new JLabel(""); loginFeedback.setForeground(Color.RED); loginFeedback.setHorizontalAlignment(SwingConstants.CENTER); loginFeedback.setBounds(83, 216, 269, 25); jContentPane.add(loginFeedback); btnRegister = new JButton("Register"); btnRegister.setBounds(222, 180, 113, 23); btnRegister.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { jButton_ActionPerformed2(arg0); } }); jContentPane.add(btnRegister); } return jContentPane; } private void jButton_ActionPerformed2(ActionEvent e){ this.setVisible(false); Frame a = new OwnerRegistrationGUI(); a.setVisible(true); } private void jButton_ActionPerformed(){ Account acc = null; try { acc = loginManager.checkCredentials(usernameField.getText(),new String(passwordField.getPassword())); } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (acc == null) loginFeedback.setText("Incorrect username or password"); else if( acc.getAdmin()) { this.setVisible(false); Frame a = new AdminMenuGUI(); a.setVisible(true); } else { if(acc.getOwner()==null){ loginFeedback.setText("Incorrect username or password"); }else{ this.setVisible(false); Frame a = new OwnerMenuGUI(acc.getOwner()); a.setVisible(true); } } } } // @jve:decl-index=0:visual-constraint="222,33" |
Commits for RRRRHHHH_CoderuralHouses client/src/gui/LoginGUI.java
Revision | Author | Commited | Message |
---|---|---|---|
4f8bcc ... | epinzolas001 | Mon 18 May, 2015 09:49:54 +0000 | Merge conflicts solutioned |