6 import java.awt.Rectangle;
7 import java.util.Vector;
9 import businessLogic.*;
11 import domain.RuralHouse;
13 import java.awt.event.ActionListener;
14 import java.awt.event.ActionEvent;
15 import java.awt.Color;
17 public class LoginGUI extends JFrame {
19 private static final long serialVersionUID= 1L;
20 private JPanel jContentPane = null;
21 private JTextField usernameField;
22 private JPasswordField passwordField;
23 private LoginManagerInterface loginManager = new LoginManager();
24 private JLabel loginFeedback;
31 private void initialize() {
32 this.setSize(449, 293);
33 this.setContentPane(getJContentPane());
34 this.setTitle("Login");
38 private JPanel getJContentPane() {
39 if (jContentPane == null) {
40 jContentPane = new JPanel();
41 jContentPane.setLayout(null);
43 JLabel usernameTag = new JLabel("Username:");
44 usernameTag.setBounds(56, 67, 104, 20);
45 jContentPane.add(usernameTag);
47 JLabel passwordTag = new JLabel("Password:");
48 passwordTag.setBounds(56, 132, 104, 15);
49 jContentPane.add(passwordTag);
51 usernameField = new JTextField();
52 usernameField.setBounds(202, 65, 133, 25);
53 jContentPane.add(usernameField);
54 usernameField.setColumns(10);
56 passwordField = new JPasswordField();
57 passwordField.setBounds(202, 122, 133, 25);
58 jContentPane.add(passwordField);
60 JButton loginButton = new JButton("Login");
61 loginButton.addActionListener(new ActionListener() {
62 public void actionPerformed(ActionEvent arg0) {
63 jButton_ActionPerformed(arg0);
66 loginButton.setBounds(164, 179, 117, 25);
67 jContentPane.add(loginButton);
69 loginFeedback = new JLabel("");
70 loginFeedback.setForeground(Color.RED);
71 loginFeedback.setHorizontalAlignment(SwingConstants.CENTER);
72 loginFeedback.setBounds(83, 216, 269, 25);
73 jContentPane.add(loginFeedback);
78 private void jButton_ActionPerformed(ActionEvent e){
79 Owner owner = loginManager.checkCredentials(usernameField.getText(),new String(passwordField.getPassword()));
81 loginFeedback.setText("Incorrect username or password");
83 Vector<RuralHouse> ownerHouseList=null;
85 ownerHouseList = StartWindow.getBusinessLogic().getRuralHouses(owner);
86 }catch (Exception e1){
89 if(!ownerHouseList.isEmpty()){
90 this.setVisible(false);
91 Frame a = new IntroduceOffer2GUI(ownerHouseList);
94 else if(ownerHouseList.isEmpty())
95 loginFeedback.setText("Login OK , but no houses in your name");
100 } // @jve:decl-index=0:visual-constraint="222,33"