-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogGui.java
More file actions
197 lines (153 loc) · 5.71 KB
/
logGui.java
File metadata and controls
197 lines (153 loc) · 5.71 KB
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
package com.company;
import java.awt.BorderLayout;
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 javax.swing.border.TitledBorder;
public class logGui extends JFrame {
private JTextField textuser;
private JLabel labeluser;
private JTextField textpass;
private JLabel labelpass;
private JTextField textlog;
private JLabel labellog;
public String username;
public String password;
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>();
/**
* <p>
*this is the gui for the log in made with java swing and gets info from logreg.java
*<br>
* @param -
* @return ausers
* @see -
* @author tsig-404
*/
public logGui(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
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 imgName = "images/Login2.png";
URL imageURL = this.getClass().getResource(imgName);
ImageIcon icon = new ImageIcon(imageURL);
//JMenuItem menuFileOpen = new JMenuItem("Open", icon);
setTitle("Login Tab");
setLocationRelativeTo(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setResizable(true);
JPanel panel1 = new JPanel();
TitledBorder border = BorderFactory.createTitledBorder(" Login ");
panel1.setBorder(border);
GridLayout layout = new GridLayout(4, 2, 2, 2);
panel1.setLayout(layout);
labeluser = new JLabel("Username:");
panel1.add(labeluser);
textuser = new JTextField("");
panel1.add(textuser);
labelpass = new JLabel("password:");
panel1.add(labelpass);
textpass = new JTextField("");
panel1.add(textpass);
labellog = new JLabel("");
panel1.add(labellog);
textlog = new JTextField("");
textlog.setEditable(false);
panel1.add(textlog);
add(panel1, BorderLayout.CENTER);
JPanel panel2 = new JPanel();
JButton buttonCalculate = new JButton("Login");
buttonCalculate.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
//System.exit(502);
trlog();
//textDose.setText(String.valueOf(Math.round(dose)));
}
});
panel2.add(buttonCalculate);
add(panel2, BorderLayout.PAGE_END);
//calculateDose();
pack();
setVisible(true);
}
/**
* <p>
*this use the info from logreg and send the users to their menus
*<br>
* @param -
* @return ausers
* @see -
* @author tsig-404
*/
private void trlog() {
username = new String(textuser.getText());
password = new String(textpass.getText());
System.out.println(username);
System.out.println(password);
Logreg ii=new Logreg();
int tri=ii.guiLogin(username,password,ausers);
if(tri==1)
{
textlog.setText("sucessfull login");
setVisible(false);
Logreg zz=new Logreg();
int cm=zz.guiMenus(ausers,rentals,user,rented,rentalsV2,rentcancel,messages,roles,
username);
if(cm==11)
{
System.out.println("admin:"+username);
AmenuGui aa=new AmenuGui(username,ausers,rentals,user,rented,rentalsV2,rentcancel,messages,roles);
}
else if(cm==22)
{
System.out.println("client:"+username);
CmenuGui cc=new CmenuGui(username,ausers,rentals,user,rented,rentalsV2,rentcancel,messages,roles);
}
else if(cm==33)
{
System.out.println("provider:"+username);
PmenuGui pp=new PmenuGui(username,ausers,rentals,user,rented,rentalsV2,rentcancel,messages,roles);
}
else
{
System.out.println("da fuck i dont work here");
}
//logGui frame = new logGui(ausers,rentals,user,rented,rentalsV2,rentcancel,messages,roles);
}
else if (tri==0) {
textlog.setText("unsucessfull login");
}
else
{
textlog.setText("da fuck i dont work here");
}
}
public String getUsr()
{
return username;
}
public String getPasw()
{
return password;
}
}