House Features added and logic for adding options to the owner
[RRRRHHHH_Code] / ruralHouses / src / gui / LoginGUI.java
similarity index 70%
rename from ruralHouses/src/gui/IntroduceOfferGUI.java
rename to ruralHouses/src/gui/LoginGUI.java
index ee56946..ef333d6 100644 (file)
@@ -14,7 +14,7 @@ import java.awt.event.ActionListener;
 import java.awt.event.ActionEvent;
 import java.awt.Color;
 
-public class IntroduceOfferGUI extends JFrame {
+public class LoginGUI extends JFrame {
 
        private static final long serialVersionUID= 1L;
        private JPanel jContentPane = null;
@@ -23,7 +23,7 @@ public class IntroduceOfferGUI extends JFrame {
        private LoginManagerInterface loginManager = new LoginManager();
        private JLabel loginFeedback;
 
-       public IntroduceOfferGUI() {
+       public LoginGUI() {
                super();
                initialize();
        }
@@ -60,25 +60,8 @@ public class IntroduceOfferGUI extends JFrame {
                        JButton loginButton = new JButton("Login");
                        loginButton.addActionListener(new ActionListener() {
                                public void actionPerformed(ActionEvent arg0) {
-                                       Owner owner = loginManager.checkCredentials(usernameField.getText(),new String(passwordField.getPassword()));
-                                       if(owner==null){
-                                               loginFeedback.setText("Incorrect username or password");
-                                       }else{
-                                               Vector<RuralHouse> ownerHouseList=null;
-                                               try{
-                                                       ownerHouseList = StartWindow.getBusinessLogic().getRuralHouses(owner);
-                                               }catch (Exception e){
-                                                       e.printStackTrace();
-                                               }
-                                               if(!ownerHouseList.isEmpty()){
-                                                       Frame a = new IntroduceOffer2GUI(ownerHouseList);       
-                                                       a.setVisible(true);
-                                               }
-                                               else if(ownerHouseList.isEmpty())
-                                                       loginFeedback.setText("Login OK , but no houses in your name");
-                                       }
-
-                               }
+                               jButton_ActionPerformed(arg0);  
+                               }                                       
                        });
                        loginButton.setBounds(164, 179, 117, 25);
                        jContentPane.add(loginButton);
@@ -91,7 +74,28 @@ public class IntroduceOfferGUI extends JFrame {
                }
                return jContentPane;
        }
+       
+       private void jButton_ActionPerformed(ActionEvent e){
+               Owner owner = loginManager.checkCredentials(usernameField.getText(),new String(passwordField.getPassword()));
+               if(owner==null){
+                       loginFeedback.setText("Incorrect username or password");
+               }else{
+                       Vector<RuralHouse> ownerHouseList=null;
+                       try{
+                               ownerHouseList = StartWindow.getBusinessLogic().getRuralHouses(owner);
+                       }catch (Exception e1){
+                               e1.printStackTrace();
+                       }
+                       if(!ownerHouseList.isEmpty()){
+                               this.setVisible(false);
+                               Frame a = new IntroduceOffer2GUI(ownerHouseList);
+                               a.setVisible(true);
+                       }
+                       else if(ownerHouseList.isEmpty())
+                               loginFeedback.setText("Login OK , but no houses in your name");
+               }
 
+       }
 
 }  // @jve:decl-index=0:visual-constraint="222,33"