-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrimary_Screen.java
More file actions
620 lines (554 loc) · 31.8 KB
/
Primary_Screen.java
File metadata and controls
620 lines (554 loc) · 31.8 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
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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template
*/
package Rent_Rover;
/**
*
* @author PC MOD NEPAL
*/
import Rent_Rover.DataBases.DB;
import java.awt.Color;
import Rent_Rover.GradientPanel;
import Rent_Rover.GradientPanel.Direction;
import java.awt.Image;
import java.util.List;
import javax.swing.ImageIcon;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JMenuItem;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class Primary_Screen extends javax.swing.JFrame {
private static final java.util.logging.Logger logger = java.util.logging.Logger.getLogger(Primary_Screen.class.getName());
private javax.swing.JPopupMenu suggestionPopup = new javax.swing.JPopupMenu();
/**
* Creates new form Primary_Screen
*/
public Primary_Screen() {
initComponents();
ImageScaler.setScaledImage(RR_logo, "C:\\Users\\97798\\Desktop\\ProjectImages\\RR logo.png");
ImageScaler.setScaledImage(CarLogo, "C:\\Users\\97798\\Desktop\\ProjectImages\\lincoln navigator.png");
ImageScaler.setScaledImage(Calendar,"C:\\Users\\97798\\Desktop\\ProjectImages\\calendar.png" );
ImageScaler.setScaledImage(calendar2,"C:\\Users\\97798\\Desktop\\ProjectImages\\calendar.png" );
ImageScaler.setScaledImage(pickuplogo,"C:\\Users\\97798\\Desktop\\ProjectImages\\location.png" );
ImageScaler.setScaledImage(DropOfflogo,"C:\\Users\\97798\\Desktop\\ProjectImages\\location.png" );
pickuplocation.addItem("Select PickUp Location");
dropofflocation.addItem("Select DropOff Location");
loadLocations();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
bottom = new ImageScalerP("C:\\Users\\97798\\Desktop\\ProjectImages\\dune.jpg");
CarLogo = new javax.swing.JLabel();
whitepanel = new ImageScalerP("C:\\Users\\97798\\Desktop\\ProjectImages\\whitebg.jpg");
jLabel2 = new javax.swing.JLabel();
jLabel1 = new javax.swing.JLabel();
RR_logo = new javax.swing.JLabel();
homee = new javax.swing.JLabel();
login_and_signup = new ImageScalerP("C:\\Users\\97798\\Desktop\\ProjectImages\\whitebg.jpg");
Login_button = new javax.swing.JButton();
SignUp_button = new Rent_Rover.CoolButton("SignUP");
BecomeArenter = new javax.swing.JLabel();
book = new javax.swing.JPanel();
pickup = new RoundedPanel(25);
dateField1 = new RoundedTextField(25);
Calendar = new javax.swing.JLabel();
dropoff = new RoundedPanel(25);
calendar2 = new javax.swing.JLabel();
dateField2 = new RoundedTextField(25);
BOOKnow = new Rent_Rover.CoolButton("BOOK NOW");
jPanel1 = new javax.swing.JPanel();
pickuplogo = new javax.swing.JLabel();
pickuplocation = new javax.swing.JComboBox<>();
jPanel2 = new javax.swing.JPanel();
DropOfflogo = new javax.swing.JLabel();
dropofflocation = new javax.swing.JComboBox<>();
jLabel4 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setBackground(new java.awt.Color(255, 255, 255));
bottom.setBackground(new java.awt.Color(102, 255, 255));
CarLogo.setBackground(new java.awt.Color(0, 0, 255));
jLabel2.setFont(new java.awt.Font("SansSerif", 1, 12)); // NOI18N
jLabel2.setText("Rent, Ride, Repeat");
jLabel1.setFont(new java.awt.Font("Perpetua", 3, 36)); // NOI18N
jLabel1.setText("RentRover");
jLabel1.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
jLabel1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jLabel1MouseClicked(evt);
}
});
RR_logo.setMaximumSize(new java.awt.Dimension(76, 51));
homee.setFont(new java.awt.Font("SansSerif", 1, 18)); // NOI18N
homee.setText("Home");
homee.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
homee.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
homeeMouseClicked(evt);
}
});
Login_button.setFont(new java.awt.Font("Segoe UI Black", 0, 12)); // NOI18N
Login_button.setText("Login");
Login_button.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
Login_button.setBorderPainted(false);
Login_button.setFocusPainted(false);
Login_button.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
Login_buttonMouseClicked(evt);
}
});
Login_button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Login_buttonActionPerformed(evt);
}
});
SignUp_button.setText("SignUp");
SignUp_button.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
SignUp_buttonMouseClicked(evt);
}
});
SignUp_button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
SignUp_buttonActionPerformed(evt);
}
});
javax.swing.GroupLayout login_and_signupLayout = new javax.swing.GroupLayout(login_and_signup);
login_and_signup.setLayout(login_and_signupLayout);
login_and_signupLayout.setHorizontalGroup(
login_and_signupLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(login_and_signupLayout.createSequentialGroup()
.addContainerGap()
.addComponent(Login_button, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(SignUp_button)
.addContainerGap(14, Short.MAX_VALUE))
);
login_and_signupLayout.setVerticalGroup(
login_and_signupLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, login_and_signupLayout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(login_and_signupLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(Login_button, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(SignUp_button, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
);
BecomeArenter.setFont(new java.awt.Font("SansSerif", 1, 18)); // NOI18N
BecomeArenter.setText("Become a Renter");
BecomeArenter.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
BecomeArenter.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
BecomeArenterMouseClicked(evt);
}
});
javax.swing.GroupLayout whitepanelLayout = new javax.swing.GroupLayout(whitepanel);
whitepanel.setLayout(whitepanelLayout);
whitepanelLayout.setHorizontalGroup(
whitepanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(whitepanelLayout.createSequentialGroup()
.addGap(53, 53, 53)
.addComponent(RR_logo, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(whitepanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addGroup(whitepanelLayout.createSequentialGroup()
.addGap(6, 6, 6)
.addComponent(jLabel2)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(homee)
.addGap(319, 319, 319)
.addComponent(BecomeArenter)
.addGap(164, 164, 164)
.addComponent(login_and_signup, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
whitepanelLayout.setVerticalGroup(
whitepanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(whitepanelLayout.createSequentialGroup()
.addGap(22, 22, 22)
.addGroup(whitepanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(homee)
.addComponent(BecomeArenter))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, whitepanelLayout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(whitepanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(whitepanelLayout.createSequentialGroup()
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(RR_logo, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(login_and_signup, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(24, 24, 24))
);
book.setOpaque(false);
dateField1.setFont(new java.awt.Font("Perpetua", 0, 14)); // NOI18N
dateField1.setText("Select PickUp Date");
dateField1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
dateField1MouseClicked(evt);
}
});
javax.swing.GroupLayout pickupLayout = new javax.swing.GroupLayout(pickup);
pickup.setLayout(pickupLayout);
pickupLayout.setHorizontalGroup(
pickupLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pickupLayout.createSequentialGroup()
.addContainerGap()
.addComponent(Calendar, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(dateField1, javax.swing.GroupLayout.DEFAULT_SIZE, 162, Short.MAX_VALUE)
.addContainerGap())
);
pickupLayout.setVerticalGroup(
pickupLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pickupLayout.createSequentialGroup()
.addContainerGap()
.addGroup(pickupLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(Calendar, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(dateField1, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
dateField2.setFont(new java.awt.Font("Perpetua", 0, 14)); // NOI18N
dateField2.setText("Select Return Date");
dateField2.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
dateField2MouseClicked(evt);
}
});
javax.swing.GroupLayout dropoffLayout = new javax.swing.GroupLayout(dropoff);
dropoff.setLayout(dropoffLayout);
dropoffLayout.setHorizontalGroup(
dropoffLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(dropoffLayout.createSequentialGroup()
.addContainerGap()
.addComponent(calendar2, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(dateField2, javax.swing.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE)
.addContainerGap())
);
dropoffLayout.setVerticalGroup(
dropoffLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(dropoffLayout.createSequentialGroup()
.addContainerGap()
.addGroup(dropoffLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(calendar2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(dateField2, javax.swing.GroupLayout.DEFAULT_SIZE, 33, Short.MAX_VALUE))
.addContainerGap())
);
BOOKnow.setText("Search Now");
BOOKnow.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
BOOKnowActionPerformed(evt);
}
});
jPanel1.setOpaque(false);
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(pickuplogo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(pickuplocation, javax.swing.GroupLayout.PREFERRED_SIZE, 376, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(pickuplogo, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(pickuplocation))
.addContainerGap())
);
jPanel2.setOpaque(false);
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(DropOfflogo, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(dropofflocation, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(DropOfflogo, javax.swing.GroupLayout.DEFAULT_SIZE, 45, Short.MAX_VALUE)
.addComponent(dropofflocation))
.addContainerGap())
);
jLabel4.setFont(new java.awt.Font("Perpetua", 1, 36)); // NOI18N
jLabel4.setText("Rover on Demand");
jLabel4.setCursor(new java.awt.Cursor(java.awt.Cursor.TEXT_CURSOR));
javax.swing.GroupLayout bookLayout = new javax.swing.GroupLayout(book);
book.setLayout(bookLayout);
bookLayout.setHorizontalGroup(
bookLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, bookLayout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(bookLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(BOOKnow, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(bookLayout.createSequentialGroup()
.addComponent(pickup, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(dropoff, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(12, 12, 12))
.addGroup(bookLayout.createSequentialGroup()
.addContainerGap()
.addGroup(bookLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
.addGroup(bookLayout.createSequentialGroup()
.addGap(40, 40, 40)
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 289, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
bookLayout.setVerticalGroup(
bookLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, bookLayout.createSequentialGroup()
.addGap(22, 22, 22)
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 118, Short.MAX_VALUE)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(36, 36, 36)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(28, 28, 28)
.addGroup(bookLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(pickup, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(dropoff, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(27, 27, 27)
.addComponent(BOOKnow, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(14, 14, 14))
);
javax.swing.GroupLayout bottomLayout = new javax.swing.GroupLayout(bottom);
bottom.setLayout(bottomLayout);
bottomLayout.setHorizontalGroup(
bottomLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(whitepanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(bottomLayout.createSequentialGroup()
.addGap(101, 101, 101)
.addComponent(book, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(324, 324, 324)
.addComponent(CarLogo, javax.swing.GroupLayout.PREFERRED_SIZE, 536, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
bottomLayout.setVerticalGroup(
bottomLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(bottomLayout.createSequentialGroup()
.addGap(37, 37, 37)
.addComponent(whitepanel, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 42, Short.MAX_VALUE)
.addGroup(bottomLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(CarLogo, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 369, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(book, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(101, 101, 101))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(bottom, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(bottom, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void Login_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Login_buttonActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_Login_buttonActionPerformed
private void SignUp_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SignUp_buttonActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_SignUp_buttonActionPerformed
private void Login_buttonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_Login_buttonMouseClicked
new Form_Login().setVisible(true);
this.dispose();
}//GEN-LAST:event_Login_buttonMouseClicked
private void SignUp_buttonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_SignUp_buttonMouseClicked
new Form_SignUp().setVisible(true);
// TODO add your handling code here:
}//GEN-LAST:event_SignUp_buttonMouseClicked
private void jLabel1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel1MouseClicked
this.dispose();
new Primary_Screen().setVisible(true);
}//GEN-LAST:event_jLabel1MouseClicked
private void dateField1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_dateField1MouseClicked
// Create a calendar dialog
com.toedter.calendar.JCalendar calendar = new com.toedter.calendar.JCalendar();
// Create a dialog to hold the calendar
JDialog dialog = new JDialog();
dialog.setModal(true);
dialog.setTitle("Select Date");
dialog.getContentPane().add(calendar);
dialog.pack();
dialog.setLocationRelativeTo(dateField1);
// Add a listener to detect date selection
calendar.addPropertyChangeListener("calendar", evt2 -> {
java.util.Calendar selected = calendar.getCalendar();
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd");
dateField1.setText(sdf.format(selected.getTime()));
dialog.dispose(); // close the dialog after selection
});
dialog.setVisible(true);
}//GEN-LAST:event_dateField1MouseClicked
private void dateField2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_dateField2MouseClicked
com.toedter.calendar.JCalendar calendar = new com.toedter.calendar.JCalendar();
// Create a dialog to hold the calendar
JDialog dialog = new JDialog();
dialog.setModal(true);
dialog.setTitle("Select Date");
dialog.getContentPane().add(calendar);
dialog.pack();
dialog.setLocationRelativeTo(dateField2);
// Add a listener to detect date selection
calendar.addPropertyChangeListener("calendar", evt2 -> {
java.util.Calendar selected = calendar.getCalendar();
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd");
dateField2.setText(sdf.format(selected.getTime()));
dialog.dispose(); // close the dialog after selection
});
dialog.setVisible(true);
}//GEN-LAST:event_dateField2MouseClicked
private void loadLocations() {
try (Connection conn = DB.getConnection();
PreparedStatement ps = conn.prepareStatement("SELECT DISTINCT location FROM bookings");
ResultSet rs = ps.executeQuery()) {
while (rs.next()) {
String loc = rs.getString("location");
pickuplocation.addItem(loc);
dropofflocation.addItem(loc);
}
} catch (SQLException e) {
e.printStackTrace();
StylishPopup.showError(this, "Failed to load locations: " + e.getMessage());
}
}
private void BOOKnowActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BOOKnowActionPerformed
try {
// Get values from fields
// Get values from fields
String pickup = (String) pickuplocation.getSelectedItem();
String dropoff = (String) dropofflocation.getSelectedItem();
// Validation
if (pickup.equals("Select PickUp Location") || dropoff.equals("Select DropOff Location")) {
StylishPopup.showError(this, "Please select both pickup and dropoff locations!");
return;
}
String pickupDate = dateField1.getText().trim();
String dropoffDate = dateField2.getText().trim();
// Validate fields
if (pickup.isEmpty() || pickup.equalsIgnoreCase("PickUp Location") ||
dropoff.isEmpty() || dropoff.equalsIgnoreCase("DropOff Location") ||
pickupDate.isEmpty() || dropoffDate.isEmpty()) {
StylishPopup.showError(this, "Please fill all fields!");
return;
}
// Validate max length
if (pickup.length() > 100 || dropoff.length() > 100) {
StylishPopup.showError(this, "Location cannot exceed 100 characters!");
return;
}
// Validate dates
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd");
java.util.Date pickDateObj = sdf.parse(pickupDate);
java.util.Date dropDateObj = sdf.parse(dropoffDate);
if (!dropDateObj.after(pickDateObj) && !dropDateObj.equals(pickDateObj)) {
StylishPopup.showError(this, "Drop-off date must be same or after pick-up date!");
return;
}
// ✅ Instead of storing in DB, just go to dashboard with values
StylishPopup.showSuccess(this, "Booking Details Confirmed!");
Customer_DashBoard dashboard = new Customer_DashBoard(pickup, dropoff, pickupDate, dropoffDate);
dashboard.setVisible(true);
this.dispose();
} catch (Exception ex) {
ex.printStackTrace();
StylishPopup.showError(this, "Error: " + ex.getMessage());
}
}//GEN-LAST:event_BOOKnowActionPerformed
private void homeeMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_homeeMouseClicked
this.dispose();
new Primary_Screen().setVisible(true);
}//GEN-LAST:event_homeeMouseClicked
private void BecomeArenterMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_BecomeArenterMouseClicked
CustomPopup.showError(this, "Please Login/SignUp to Rent Your Vehicle.", "Login");
return;
}//GEN-LAST:event_BecomeArenterMouseClicked
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ReflectiveOperationException | javax.swing.UnsupportedLookAndFeelException ex) {
logger.log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(() -> new Primary_Screen().setVisible(true));
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton BOOKnow;
private javax.swing.JLabel BecomeArenter;
private javax.swing.JLabel Calendar;
private javax.swing.JLabel CarLogo;
private javax.swing.JLabel DropOfflogo;
private javax.swing.JButton Login_button;
private javax.swing.JLabel RR_logo;
private javax.swing.JButton SignUp_button;
private javax.swing.JPanel book;
private javax.swing.JPanel bottom;
private javax.swing.JLabel calendar2;
private javax.swing.JTextField dateField1;
private javax.swing.JTextField dateField2;
private javax.swing.JPanel dropoff;
private javax.swing.JComboBox<String> dropofflocation;
private javax.swing.JLabel homee;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel4;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel login_and_signup;
private javax.swing.JPanel pickup;
private javax.swing.JComboBox<String> pickuplocation;
private javax.swing.JLabel pickuplogo;
private javax.swing.JPanel whitepanel;
// End of variables declaration//GEN-END:variables
}