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;
21 public class OwnerRegistrationGUI extends JFrame {
26 private static final long serialVersionUID = 1L;
28 private JTextField nameField;
29 private JTextField userNameField;
30 private AdminInterface am = null;
31 private JTextField passField;
32 private JTextField bank1Field;
33 private JTextField bank2Field;
34 private JTextField bank3Field;
35 private JTextField bank4Field;
36 private JTextField emailField;
37 private JLabel lblWhenAcceptedYou;
38 private JLabel feedback;
43 public OwnerRegistrationGUI() {
46 am = (AdminInterface) Naming
47 .lookup(___IntNames.AdminManager);
48 } catch (Exception e1) {
49 System.out.println("Error accessing remote authentication: "
52 setTitle("Owner registration");
53 setBounds(100, 100, 500, 400);
55 panel.setBorder(new EmptyBorder(5, 5, 5, 5));
56 setContentPane(panel);
57 panel.setLayout(null);
59 JLabel nameLb = new JLabel("Name:");
60 nameLb.setBounds(37, 45, 46, 14);
63 nameField = new JTextField();
64 nameField.setBounds(147, 42, 86, 20);
66 nameField.setColumns(10);
68 JLabel lblUsername = new JLabel("Username:");
69 lblUsername.setBounds(37, 212, 69, 14);
70 panel.add(lblUsername);
72 userNameField = new JTextField();
73 userNameField.setBounds(147, 209, 86, 20);
74 panel.add(userNameField);
75 userNameField.setColumns(10);
77 JLabel lblPassword = new JLabel("Password:");
78 lblPassword.setBounds(37, 258, 69, 14);
79 panel.add(lblPassword);
81 passField = new JTextField();
82 passField.setBounds(147, 255, 86, 20);
84 passField.setColumns(10);
86 JLabel lblBankAccount = new JLabel("Bank account:");
87 lblBankAccount.setBounds(37, 94, 69, 14);
88 panel.add(lblBankAccount);
90 bank1Field = new JTextField();
91 bank1Field.setBounds(147, 91, 61, 20);
92 panel.add(bank1Field);
94 bank2Field = new JTextField();
95 bank2Field.setBounds(218, 91, 61, 20);
96 panel.add(bank2Field);
98 bank3Field = new JTextField();
99 bank3Field.setBounds(289, 91, 32, 20);
100 panel.add(bank3Field);
102 bank4Field = new JTextField();
103 bank4Field.setBounds(331, 91, 117, 20);
104 panel.add(bank4Field);
106 JButton btnSendRegistrationRequest = new JButton(
107 "Send registration request");
108 btnSendRegistrationRequest.setBounds(127, 316, 194, 23);
109 btnSendRegistrationRequest.addActionListener(new ActionListener() {
110 public void actionPerformed(ActionEvent arg0) {
112 jButton_ActionPerformed(arg0);
116 panel.add(btnSendRegistrationRequest);
118 JLabel lblEmail = new JLabel("E-mail:");
119 lblEmail.setBounds(37, 155, 46, 14);
122 emailField = new JTextField();
123 emailField.setBounds(147, 152, 148, 20);
124 panel.add(emailField);
125 emailField.setColumns(10);
127 lblWhenAcceptedYou = new JLabel(
128 "When accepted you will receive an e-mail");
129 lblWhenAcceptedYou.setForeground(Color.GREEN);
130 lblWhenAcceptedYou.setBounds(127, 291, 214, 14);
131 panel.add(lblWhenAcceptedYou);
133 feedback = new JLabel("");
134 feedback.setForeground(Color.RED);
135 feedback.setEnabled(false);
136 feedback.setBounds(127, 344, 214, 20);
140 private void jButton_ActionPerformed(ActionEvent e) {
142 Owner own = new Owner(this.nameField.getText(),
143 this.bank1Field.getText() + " " + this.bank2Field.getText()
144 + " " + this.bank3Field.getText() + " "
145 + this.bank4Field.getText(), this.emailField.getText());
149 if (this.am.addAccountRequest(this.userNameField.getText(),
150 this.passField.getText(), own)) {
151 this.am.saveInstance();
152 this.feedback.setText("Request sended");
154 this.feedback.setText("Can't send the request");
156 } catch (RemoteException e1) {
157 // TODO Auto-generated catch block
158 e1.printStackTrace();