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 IntroduceOfferGUI 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;
26 public IntroduceOfferGUI() {
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 Owner owner = loginManager.checkCredentials(usernameField.getText(),new String(passwordField.getPassword()));
65 loginFeedback.setText("Incorrect username or password");
67 Vector<RuralHouse> ownerHouseList=null;
69 ownerHouseList = StartWindow.getBusinessLogic().getRuralHouses(owner);
73 if(!ownerHouseList.isEmpty()){
74 Frame a = new IntroduceOffer2GUI(ownerHouseList);
77 else if(ownerHouseList.isEmpty())
78 loginFeedback.setText("Login OK , but no houses in your name");
83 loginButton.setBounds(164, 179, 117, 25);
84 jContentPane.add(loginButton);
86 loginFeedback = new JLabel("");
87 loginFeedback.setForeground(Color.RED);
88 loginFeedback.setHorizontalAlignment(SwingConstants.CENTER);
89 loginFeedback.setBounds(83, 216, 269, 25);
90 jContentPane.add(loginFeedback);
96 } // @jve:decl-index=0:visual-constraint="222,33"