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;
private LoginManagerInterface loginManager = new LoginManager();
private JLabel loginFeedback;
- public IntroduceOfferGUI() {
+ public LoginGUI() {
super();
initialize();
}
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);
}
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"