X-Git-Url: https://xp-dev.com/git/RRRRHHHH_Code/blobdiff_plain/d23286250fb8e8263d35aeef5e6d1683be5ac968:/ruralHouses/src/gui/IntroduceOfferGUI.java..5538790d8fc54f60de9b5c989eae82b446374aca:/ruralHouses/src/gui/LoginGUI.java diff --git a/ruralHouses/src/gui/IntroduceOfferGUI.java b/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 --- a/ruralHouses/src/gui/IntroduceOfferGUI.java +++ b/ruralHouses/src/gui/LoginGUI.java @@ -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 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 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"