-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRegui.java
204 lines (151 loc) · 5.78 KB
/
Regui.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
package com.company;
import javax.swing.*;
import javax.swing.border.TitledBorder;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.FileNotFoundException;
import java.util.HashMap;
public class Regui extends JFrame implements ActionListener{
protected String username;
protected String password;
protected String fullname;
protected String address;
protected HashMap<String, String> ausers = new HashMap<String, String>();
protected HashMap<String, String> roles = new HashMap<String, String>();
protected HashMap<String, User> user = new HashMap<String, User>();
protected HashMap<String, String> rentals = new HashMap<String, String>();
protected HashMap<String, Rentable> rentalsV2 = new HashMap<String, Rentable>();
protected HashMap<String, String> rented = new HashMap<String, String>();
protected HashMap<String, String> rentcancel = new HashMap<String, String>();
protected HashMap<String, String> messages = new HashMap<String, String>();
//gui register values
private JTextField textuser;
private JLabel labeluser;
private JTextField textpass;
private JLabel labelpass;
private JTextField textfn;
private JLabel labelfn;
private JTextField textad;
private JLabel labelad;
private JButton buttonc;
private JButton buttonr;
private JLabel cr;
private int choicer=0;
/**
* <p>
*this is the gui for register made with java swing
*<br>
* @param -
* @return
* @see -
* @author tsig-404
*/
public Regui(HashMap<String, String> aausers, HashMap<String, String> arentals,
HashMap<String, User> auser, HashMap<String, String> arented,
HashMap<String, Rentable> arentalsV2, HashMap<String, String> rc,
HashMap<String, String> msg, HashMap<String, String> aroles) {
//maybe get rid of them later nooo it works dont delete it
this.ausers=aausers;
this.rentals=arentals;
this.user=auser;
this.rented=arented;
this.rentalsV2=arentalsV2;
this.rentcancel=rc;
this.messages=msg;
this.roles=aroles;
//if it doesnt work
setSize(500, 500);
//setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//setLocationRelativeTo(null);
//setResizable(false);
setTitle("Register Tab");
setLocationRelativeTo(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setResizable(true);
JPanel panel1 = new JPanel();
TitledBorder border = BorderFactory.createTitledBorder(" Register ");
//panel1.setVerticalTextPosition(JPanel.BOTTOM);
panel1.setBorder(border);
GridLayout layout = new GridLayout(10, 10, 10, 10);
//panel1.setLayout(layout);
labeluser = new JLabel("Username:");
panel1.add(labeluser);
textuser = new JTextField("un");
panel1.add(textuser);
labelpass = new JLabel("Password:");
panel1.add(labelpass);
textpass = new JTextField("ps");
panel1.add(textpass);
labelfn = new JLabel("Full Name:");
panel1.add(labelfn);
textfn = new JTextField("fn");
panel1.add(textfn);
labelad = new JLabel("Address:");
panel1.add(labelad);
textad = new JTextField("ad");
//textDose.setEditable(false);
panel1.add(textad);
cr = new JLabel("");
buttonc = new JButton("Client");
buttonc.setVerticalTextPosition(JButton.BOTTOM);
buttonc.setHorizontalTextPosition(JButton.LEFT);
buttonc.addActionListener((ActionListener) this);
//buttonc.setText("Client");
buttonr = new JButton("Provider");
buttonr.addActionListener((ActionListener) this);
//button2.setEnabled(false);
FlowLayout aLayout = new FlowLayout();
setLayout(aLayout);
add(buttonc);
add(buttonr);
add(cr);
setVisible(true);
add(panel1, BorderLayout.CENTER);
JPanel panel2 = new JPanel();
pack();
setVisible(true);
}
/**
* <p>
*this checks which button got pressed and save the user as client or provider
*<br>
* @param -
* @return
* @see -
* @author tsig-404
*/
//@Override
//*
public void actionPerformed(ActionEvent e) {
//label1.setText("Πατήθηκε ένα κουμπί ");
//*
username = new String(textuser.getText());
password = new String(textpass.getText());
fullname= new String(textfn.getText());
address= new String(textad.getText());
if (e.getActionCommand().equals("Client")) {
cr.setText("Client register selected");
choicer=1;
Logreg ii=new Logreg();
try {
ii.guiRegister(ausers,rentals,user,rented,rentalsV2,rentcancel,messages,roles,
username,fullname,password,address,choicer);
} catch (FileNotFoundException ex) {
ex.printStackTrace();
}
}
else {
cr.setText("Provider register Selected");
choicer=2;
Logreg ii=new Logreg();
try {
ii.guiRegister(ausers,rentals,user,rented,rentalsV2,rentcancel,messages,roles,
username,fullname,password,address,choicer);
} catch (FileNotFoundException ex) {
ex.printStackTrace();
}
//ps=true;
}
}
}