Git Repository Public Repository

RRRRHHHH_Code

URLs

Copy to Clipboard

Diff Revisions e2ae30 ... vs 2ac167 ... for ruralHouses/src/gui/LoginGUI.java

Diff revisions: vs.
  @@ -15,8 +15,12 @@
15 15
16 16 import businessLogic.LoginManager;
17 17 import businessLogic.LoginManagerInterface;
18 + import domain.Account;
18 19 import domain.Owner;
19 20
21 + import javax.swing.JRadioButton;
22 + import javax.swing.ButtonGroup;
23 +
20 24 public class LoginGUI extends JFrame {
21 25
22 26 private static final long serialVersionUID= 1L;
  @@ -25,7 +29,7 @@
25 29 private JPasswordField passwordField;
26 30 private LoginManagerInterface loginManager = new LoginManager();
27 31 private JLabel loginFeedback;
28 -
32 + private final ButtonGroup buttonGroup = new ButtonGroup();
29 33 public LoginGUI() {
30 34 super();
31 35 initialize();
  @@ -80,19 +84,22 @@
80 84 }
81 85
82 86 private void jButton_ActionPerformed(ActionEvent e){
83 - Owner owner = loginManager.checkCredentials(usernameField.getText(),new String(passwordField.getPassword()));
84 - if(owner==null){
85 - loginFeedback.setText("Incorrect username or password");
86 - }else{
87 -
88 -
89 87
88 + Account acc = loginManager.checkCredentials(usernameField.getText(),new String(passwordField.getPassword()));
89 + if (acc.getAdmin()) {
90 + this.setVisible(false);
91 + Frame a = new AdminMenuGUI();
92 + a.setVisible(true);
93 + } else {
94 + if(acc.getOwner()==null){
95 + loginFeedback.setText("Incorrect username or password");
96 + }else{
90 97 this.setVisible(false);
91 - Frame a = new OwnerMenuGUI(owner);
92 - a.setVisible(true);
93 - }
94 -
98 + Frame a = new OwnerMenuGUI(acc.getOwner());
99 + a.setVisible(true);
100 + }
101 + }
102 +
95 103 }
96 -
97 104 } // @jve:decl-index=0:visual-constraint="222,33"
98 105