4 import java.awt.event.ActionEvent;
5 import java.awt.event.ActionListener;
6 import java.rmi.Naming;
7 import java.rmi.RemoteException;
9 import javax.swing.JButton;
10 import javax.swing.JFrame;
11 import javax.swing.JLabel;
12 import javax.swing.JPanel;
13 import javax.swing.JTextField;
14 import javax.swing.border.EmptyBorder;
16 import common.AdminInterface;
18 import configuration.___IntNames;
19 import domain.Account;
22 public class OwnerRegistrationGUI extends JFrame {
25 private JTextField nameField;
26 private JTextField userNameField;
27 private AdminInterface am = null;
28 private JTextField passField;
29 private JTextField bank1Field;
30 private JTextField bank2Field;
31 private JTextField bank3Field;
32 private JTextField bank4Field;
33 private JTextField emailField;
34 private JLabel lblWhenAcceptedYou;
35 private JLabel feedback;
40 public OwnerRegistrationGUI() {
43 am = (AdminInterface) Naming
44 .lookup(___IntNames.AdminManager);
45 } catch (Exception e1) {
46 System.out.println("Error accessing remote authentication: "
49 setTitle("Owner registration");
50 setBounds(100, 100, 500, 400);
52 panel.setBorder(new EmptyBorder(5, 5, 5, 5));
53 setContentPane(panel);
54 panel.setLayout(null);
56 JLabel nameLb = new JLabel("Name:");
57 nameLb.setBounds(37, 45, 46, 14);
60 nameField = new JTextField();
61 nameField.setBounds(147, 42, 86, 20);
63 nameField.setColumns(10);
65 JLabel lblUsername = new JLabel("Username:");
66 lblUsername.setBounds(37, 212, 69, 14);
67 panel.add(lblUsername);
69 userNameField = new JTextField();
70 userNameField.setBounds(147, 209, 86, 20);
71 panel.add(userNameField);
72 userNameField.setColumns(10);
74 JLabel lblPassword = new JLabel("Password:");
75 lblPassword.setBounds(37, 258, 69, 14);
76 panel.add(lblPassword);
78 passField = new JTextField();
79 passField.setBounds(147, 255, 86, 20);
81 passField.setColumns(10);
83 JLabel lblBankAccount = new JLabel("Bank account:");
84 lblBankAccount.setBounds(37, 94, 69, 14);
85 panel.add(lblBankAccount);
87 bank1Field = new JTextField();
88 bank1Field.setBounds(147, 91, 61, 20);
89 panel.add(bank1Field);
91 bank2Field = new JTextField();
92 bank2Field.setBounds(218, 91, 61, 20);
93 panel.add(bank2Field);
95 bank3Field = new JTextField();
96 bank3Field.setBounds(289, 91, 32, 20);
97 panel.add(bank3Field);
99 bank4Field = new JTextField();
100 bank4Field.setBounds(331, 91, 117, 20);
101 panel.add(bank4Field);
103 JButton btnSendRegistrationRequest = new JButton(
104 "Send registration request");
105 btnSendRegistrationRequest.setBounds(127, 316, 194, 23);
106 btnSendRegistrationRequest.addActionListener(new ActionListener() {
107 public void actionPerformed(ActionEvent arg0) {
109 jButton_ActionPerformed(arg0);
113 panel.add(btnSendRegistrationRequest);
115 JLabel lblEmail = new JLabel("E-mail:");
116 lblEmail.setBounds(37, 155, 46, 14);
119 emailField = new JTextField();
120 emailField.setBounds(147, 152, 148, 20);
121 panel.add(emailField);
122 emailField.setColumns(10);
124 lblWhenAcceptedYou = new JLabel(
125 "When accepted you will receive an e-mail");
126 lblWhenAcceptedYou.setForeground(Color.GREEN);
127 lblWhenAcceptedYou.setBounds(127, 291, 214, 14);
128 panel.add(lblWhenAcceptedYou);
130 feedback = new JLabel("");
131 feedback.setForeground(Color.RED);
132 feedback.setEnabled(false);
133 feedback.setBounds(127, 344, 214, 20);
137 private void jButton_ActionPerformed(ActionEvent e) {
139 Owner own = new Owner(this.nameField.getText(),
140 this.bank1Field.getText() + " " + this.bank2Field.getText()
141 + " " + this.bank3Field.getText() + " "
142 + this.bank4Field.getText(), this.emailField.getText());
146 if (this.am.addAccountRequest(this.userNameField.getText(),
147 this.passField.getText(), own)) {
148 this.am.saveInstance();
149 this.feedback.setText("Request sended");
151 this.feedback.setText("Can't send the request");
153 } catch (RemoteException e1) {
154 // TODO Auto-generated catch block
155 e1.printStackTrace();