-
Notifications
You must be signed in to change notification settings - Fork 0
/
lrGui.java
199 lines (157 loc) · 5.36 KB
/
lrGui.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
package com.company;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.URL;
import java.util.HashMap;
import javax.swing.*;
import java.awt.Component;
import java.awt.Container;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import static java.awt.SystemColor.text;
/**
* <p>
*this is the start up menu to choose between login and register
*<br>
* @param -
* @return -
* @see -
* @author tsig-404
*/
//this is the start of the ui which send to login or register
public class lrGui extends JFrame implements ActionListener {
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>();
private JLabel label1;
private JButton button1;
private JButton button2;
private JLabel bd;
protected int choice=0;
protected boolean ps=false;
public void setLabelText(String str) {
label1.setText(str);
}
/**
* <p>
*this is the ui of it with jpanels and jframes and jbuttons and jlabels with java swing
*<br>
* @param -
* @return -
* @see -
* @author tsig-404
*/
public lrGui(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) {
super("Login/Register");
//setTitle("Επίδειξη JButton");
setSize(270, 100);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLocationRelativeTo(null);
//setResizable(false);
//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
String imgName4 = "images/beflog.png";
URL imageURL4 = this.getClass().getResource(imgName4);
ImageIcon icon4 = new ImageIcon(imageURL4);
bd = new JLabel(icon4 );
label1 = new JLabel("");
button1 = new JButton();
button1.addActionListener(this);
button1.setText("Login");
button2 = new JButton("Register");
button2.addActionListener(this);
//button2.setEnabled(false);
//
JFrame box0 = new JFrame("down");
JPanel box1 = new JPanel();
//buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
box1.setLayout(new BoxLayout(box1, BoxLayout.Y_AXIS));
FlowLayout aLayout = new FlowLayout();
//BoxLayout bLayout = new BoxLayout();
//setLayout((LayoutManager) box1);
setLayout(aLayout);
//addAButton("Button 1", box0);
//addAButton("Button 2", box0);
//addAButton("Button 3", box0);
box0.add(button1);
box0.add(button2);
box0.add(label1);
box0.pack();
//box0.setVisible(true);
//add(bd);
//add(icon4);
add(button1);
add(button2);
add(label1);
//createAndShowGUI();
setVisible(true);
}
/**
* <p>
*this is activated if the user choose to press one of the buttons to send him to the next
* window also it set it to non visible
*<br>
* @param -
* @return -
* @see -
* @author tsig-404
*/
@Override
//*
public void actionPerformed(ActionEvent e) {
//label1.setText("Πατήθηκε ένα κουμπί ");
//*
if (e.getActionCommand().equals("Login")) {
label1.setText("Login Selected");
choice=1;
ps=true;
setVisible(false);
logGui frame = new logGui(ausers,rentals,user,rented,rentalsV2,rentcancel,messages,roles);
} else {
label1.setText("Register Selected");
choice=2;
ps=true;
setVisible(false);
Regui frame= new Regui(ausers,rentals,user,rented,rentalsV2,rentcancel,messages,roles);
}
//*/
}
/**
* <p>
*this returns the choice to the main because without it it doesnt wait to get a input
*<br>
* @param -
* @return choice
* @see -
* @author tsig-404
*/
//maybe it doesnt work as it should
public int ch()
{
int sec=0;
while(ps==false) {
sec++;
}
label1.setText(String.valueOf(choice));
return choice;
}
}