-
Notifications
You must be signed in to change notification settings - Fork 0
/
DefaultWorker.java
245 lines (202 loc) · 7.29 KB
/
DefaultWorker.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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
public class DefaultWorker extends JFrame {
private Container c;
private ImageIcon icon;
private JLabel label1, label2, label3, imgLabel;
private Font f1, f2, f3, f4, f5;
private ImageIcon logo;
private JButton btn1, btn2, btn3, nBtn;
private Cursor cursor;
private ButtonGroup radioButtonGroup;
private JRadioButton pack1, pack2, pack3;
private int selected = 0;
DefaultWorker() {
// Frame Layout
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setTitle("Rent Management");
this.setSize(1000, 500);
this.setLocationRelativeTo(null);
this.setResizable(false);
c = this.getContentPane();
c.setLayout(null);
c.setBackground(Color.decode("#F2F2F2"));
// Icon
icon = new ImageIcon(getClass().getResource("/images/icon.png"));
this.setIconImage(icon.getImage());
// Fonts
f1 = new Font("Segoe UI Black", Font.PLAIN, 30);
f2 = new Font("Segoe UI Semibold", Font.BOLD, 25);
f3 = new Font("Segoe UI", Font.PLAIN, 25);
f4 = new Font("Segoe UI", Font.PLAIN, 20);
f5 = new Font("Segoe UI Black", Font.PLAIN, 25);
cursor = new Cursor(Cursor.HAND_CURSOR);
// Title
label1 = new JLabel();
label1.setText("3 Workers are Available to Rent:");
label1.setBounds(200, 35, 600, 50);
label1.setFont(f1);
c.add(label1);
// Pack 1 Details
pack1 = new JRadioButton("Worker 1");
pack1.setBounds(150, 120, 150, 50);
pack1.setFont(f3);
pack1.setBackground(Color.decode("#F2F2F2"));
pack1.setCursor(cursor);
c.add(pack1);
label3 = new JLabel();
label3.setText("* Name: Hasib");
label3.setBounds(150, 150, 520, 50);
label3.setFont(f4);
c.add(label3);
label3 = new JLabel();
label3.setText("* Gender: Male");
label3.setBounds(150, 180, 520, 50);
label3.setFont(f4);
c.add(label3);
label3 = new JLabel();
label3.setText("* Work day: 6 days");
label3.setBounds(150, 210, 520, 50);
label3.setFont(f4);
c.add(label3);
label3 = new JLabel();
label3.setText("* Cost: 3000 Taka");
label3.setBounds(150, 240, 520, 50);
label3.setFont(f4);
c.add(label3);
// Pack 2 Details
pack2 = new JRadioButton("Worker 2");
pack2.setBounds(400, 120, 150, 50);
pack2.setFont(f3);
pack2.setBackground(Color.decode("#F2F2F2"));
pack2.setCursor(cursor);
c.add(pack2);
label3 = new JLabel();
label3.setText("* Name: Sultana");
label3.setBounds(400, 150, 500, 50);
label3.setFont(f4);
c.add(label3);
label3 = new JLabel();
label3.setText("* Gender: Female");
label3.setBounds(400, 180, 500, 50);
label3.setFont(f4);
c.add(label3);
label3 = new JLabel();
label3.setText("* Work day: 6 days");
label3.setBounds(400, 210, 500, 50);
label3.setFont(f4);
c.add(label3);
label3 = new JLabel();
label3.setText("* Cost: 4000 Taka");
label3.setBounds(400, 240, 500, 50);
label3.setFont(f4);
c.add(label3);
// Pack 3 Details
pack3 = new JRadioButton("Worker 3");
pack3.setBounds(640, 120, 150, 50);
pack3.setFont(f3);
pack3.setBackground(Color.decode("#F2F2F2"));
pack3.setCursor(cursor);
c.add(pack3);
label3 = new JLabel();
label3.setText("* Name: Habiba");
label3.setBounds(640, 150, 500, 50);
label3.setFont(f4);
c.add(label3);
label3 = new JLabel();
label3.setText("* Gender: Female");
label3.setBounds(640, 180, 500, 50);
label3.setFont(f4);
c.add(label3);
label3 = new JLabel();
label3.setText("* Work day: 6 days");
label3.setBounds(640, 210, 500, 50);
label3.setFont(f4);
c.add(label3);
label3 = new JLabel();
label3.setText("* Cost: 5000 Taka");
label3.setBounds(640, 240, 500, 50);
label3.setFont(f4);
c.add(label3);
// To group the radio buttons.
radioButtonGroup = new ButtonGroup();
radioButtonGroup.add(pack1);
radioButtonGroup.add(pack2);
radioButtonGroup.add(pack3);
// JButtons
btn1 = new JButton("Exit");
btn1.setBounds(90, 375, 215, 50);
btn1.setFont(f5);
btn1.setCursor(cursor);
btn1.setForeground(Color.WHITE);
btn1.setBackground(Color.decode("#C00000"));
c.add(btn1);
btn2 = new JButton("Back");
btn2.setBounds(384, 375, 215, 50);
btn2.setFont(f5);
btn2.setCursor(cursor);
btn2.setForeground(Color.WHITE);
btn2.setBackground(Color.decode("#226135"));
c.add(btn2);
btn3 = new JButton("Next");
btn3.setBounds(660, 375, 215, 50);
btn3.setFont(f5);
btn3.setCursor(cursor);
btn3.setForeground(Color.WHITE);
btn3.setBackground(Color.decode("#226135"));
c.add(btn3);
nBtn = new JButton("");
nBtn.setBounds(0, 0, 0, 0);
c.add(nBtn);
Handler handler = new Handler();
pack1.addActionListener(handler);
pack2.addActionListener(handler);
pack3.addActionListener(handler);
// Action Listener for JButtons
// Exit Button
btn1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
System.exit(0);
}
});
// Back Button
btn2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
setVisible(false);
WorkerOptions frame = new WorkerOptions();
frame.setVisible(true);
}
});
// Next Button
btn3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
if (selected == 0) {
JOptionPane.showMessageDialog(null, "You did not select anything.", "Warming!!!",
JOptionPane.WARNING_MESSAGE);
} else {
setVisible(false);
Payment frame = new Payment();
frame.setVisible(true);
}
}
});
}
class Handler implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == pack1) {
selected = 1;
} else if (e.getSource() == pack2) {
selected = 2;
} else if (e.getSource() == pack3) {
selected = 3;
}
}
}
public static void main(String[] args) {
DefaultWorker frame = new DefaultWorker();
frame.setVisible(true);
}
}