-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathyour_bookings.java
More file actions
679 lines (558 loc) · 27.6 KB
/
Copy pathyour_bookings.java
File metadata and controls
679 lines (558 loc) · 27.6 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
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
/*
* 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 Rent_Rover.GradientPanel;
import Rent_Rover.GradientPanel.Direction;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.QRCodeWriter;
import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.sun.tools.javac.Main;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.nio.file.*;
import java.sql.*;
import java.util.Base64;
import java.util.Calendar;
import java.util.List;
import javax.imageio.ImageIO;
import javax.swing.*;
import javax.swing.border.Border;
public class your_bookings extends javax.swing.JFrame {
private static final java.util.logging.Logger logger = java.util.logging.Logger.getLogger(your_bookings.class.getName());
private javax.swing.JPopupMenu suggestionPopup = new javax.swing.JPopupMenu();
/**
* Creates new form Primary_Screen
*/
private String username;
public your_bookings(String username) {
initComponents();
// Store username for later use
this.username = username;
// Fetch and set profile picture and name using the username
setProfilePicture(this.username);
// ✅ Set layout for scrollablepanel
scrollablepanel.setLayout(new BoxLayout(scrollablepanel, BoxLayout.Y_AXIS));
scrollablepanel.setBackground(Color.WHITE);
jScrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
jScrollPane1.setViewportView(scrollablepanel);
// then call loadBookings() (you probably already do this)
loadBookings();
}
private void setProfilePicture(String username) {
try {
Connection con = DB.getConnection();
String query = "SELECT profile_picture FROM customer WHERE username = ?";
PreparedStatement ps = con.prepareStatement(query);
ps.setString(1, username);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
byte[] imgBytes = rs.getBytes("profile_picture");
if (imgBytes != null) {
ImageIcon imageIcon = new ImageIcon(imgBytes);
Image image = imageIcon.getImage().getScaledInstance(pfp.getWidth(), pfp.getHeight(), Image.SCALE_SMOOTH);
pfp.setIcon(new ImageIcon(image));
CircularLabel.makeCircular(pfp);
}
}
rs.close();
ps.close();
con.close();
} catch (Exception e) {
e.printStackTrace();
}
}
public your_bookings() {
initComponents();
ImageScaler.setScaledImage(RR_logo, "C:\\Users\\97798\\Desktop\\ProjectImages\\RR logo.png");
scrollablepanel.setLayout(new BoxLayout(scrollablepanel, BoxLayout.Y_AXIS));
scrollablepanel.setBackground(Color.WHITE);
}
/**
* 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")
// Method to load all bookings for the logged-in user
// Updated createBookingPanel to include owner username and make panel clickable
// Updated createBookingPanel to include hover effect and full click functionality
private JPanel createBookingPanel(String vehicleName, byte[] vehicleImage,
String location, String createdAt,
String pricePerDay, String ownerUsername,
String bookedBy,
String pickupLocation, String dropoffLocation,
String pickupDate, String dropoffDate) {
final int CARD_HEIGHT = 220; // increased height
final int CARD_WIDTH = 1000;
JPanel panel = new JPanel(null);
panel.setPreferredSize(new Dimension(CARD_WIDTH, CARD_HEIGHT));
panel.setMaximumSize(new Dimension(Integer.MAX_VALUE, CARD_HEIGHT));
panel.setAlignmentX(Component.LEFT_ALIGNMENT);
panel.setBackground(Color.WHITE);
panel.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
// Vehicle image
JLabel imageLabel = new JLabel();
imageLabel.setBounds(10, 10, 130, 130);
if (vehicleImage != null && vehicleImage.length > 0) {
ImageIcon icon = new ImageIcon(vehicleImage);
Image scaled = icon.getImage().getScaledInstance(imageLabel.getWidth(), imageLabel.getHeight(), Image.SCALE_SMOOTH);
imageLabel.setIcon(new ImageIcon(scaled));
} else {
imageLabel.setText("No Image");
imageLabel.setHorizontalAlignment(SwingConstants.CENTER);
imageLabel.setVerticalAlignment(SwingConstants.CENTER);
imageLabel.setBorder(BorderFactory.createLineBorder(Color.GRAY));
}
panel.add(imageLabel);
// Vehicle name
JLabel nameLabel = new JLabel(vehicleName);
nameLabel.setFont(new Font("SansSerif", Font.BOLD, 16));
nameLabel.setBounds(150, 10, 500, 26);
panel.add(nameLabel);
// Owner username
JLabel ownerLabel = new JLabel("Owner: " + (ownerUsername == null ? "unknown" : ownerUsername));
ownerLabel.setFont(new Font("SansSerif", Font.PLAIN, 13));
ownerLabel.setBounds(150, 40, 300, 20);
panel.add(ownerLabel);
// Location + price
JLabel locPrice = new JLabel("Location: " + location + " | Price/day: Rs " + pricePerDay);
locPrice.setFont(new Font("SansSerif", Font.PLAIN, 13));
locPrice.setBounds(150, 65, 600, 20);
panel.add(locPrice);
// Pickup and Dropoff details
JLabel pickupLabel = new JLabel("Pickup: " + pickupLocation + " on " + pickupDate);
pickupLabel.setFont(new Font("SansSerif", Font.PLAIN, 13));
pickupLabel.setBounds(150, 90, 400, 20);
panel.add(pickupLabel);
JLabel dropoffLabel = new JLabel("Dropoff: " + dropoffLocation + " on " + dropoffDate);
dropoffLabel.setFont(new Font("SansSerif", Font.PLAIN, 13));
dropoffLabel.setBounds(150, 115, 400, 20);
panel.add(dropoffLabel);
// Created at
JLabel dateLabel = new JLabel("Listed On: " + createdAt);
dateLabel.setFont(new Font("SansSerif", Font.PLAIN, 12));
dateLabel.setForeground(Color.GRAY);
dateLabel.setBounds(150, 140, 400, 18);
panel.add(dateLabel);
// Booking status label
JLabel bookedByLabel = new JLabel();
bookedByLabel.setFont(new Font("SansSerif", Font.BOLD, 13));
bookedByLabel.setForeground(Color.BLUE);
bookedByLabel.setBounds(150, 165, 400, 20);
panel.add(bookedByLabel);
bookedByLabel.setText(bookedBy != null && !bookedBy.isEmpty() ? "Booked by: " + bookedBy : "");
// QR Code button
JButton qrBtn = new JButton("Show QR");
qrBtn.setBounds(650, 115, 100, 25);
panel.add(qrBtn);
qrBtn.addActionListener(e -> {
try {
JPanel receiptPanel = new JPanel() {
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
g.setFont(new Font("Arial", Font.BOLD, 16));
g.drawString("Car Booking Info", 80, 30);
g.setFont(new Font("Arial", Font.PLAIN, 14));
int y = 70; // starting y for text
int textHeight = 0;
g.drawString("Vehicle: " + vehicleName, 20, y); textHeight += 30; y += 30;
g.drawString("Owner: " + ownerUsername, 20, y); textHeight += 30; y += 30;
g.drawString("Pickup Location: " + pickupLocation, 20, y); textHeight += 25; y += 25;
g.drawString("Dropoff Location: " + dropoffLocation, 20, y); textHeight += 25; y += 25;
g.drawString("Pickup Date: " + pickupDate, 20, y); textHeight += 25; y += 25;
g.drawString("Dropoff Date: " + dropoffDate, 20, y); textHeight += 25; y += 25;
g.drawString("Location: " + location, 20, y); textHeight += 30; y += 30;
g.drawString("Price/day: Rs " + pricePerDay, 20, y); textHeight += 30;
// Vehicle image
if (vehicleImage != null && vehicleImage.length > 0) {
try {
BufferedImage img = ImageIO.read(new ByteArrayInputStream(vehicleImage));
int imgWidth = 160; // larger image
int imgHeight = 120;
// Vertical center relative to text block
int textTop = 70;
int textBottom = textTop + textHeight;
int imgY = textTop + (textBottom - textTop - imgHeight) / 2;
int imgX = this.getWidth() - imgWidth - 20; // use 'this' instead of receiptPanel
g.drawImage(img, imgX, imgY, imgWidth, imgHeight, null);
} catch (Exception ex) { ex.printStackTrace(); }
}
}
};
// Adjust panel size to fit everything
receiptPanel.setPreferredSize(new Dimension(500, 380));
receiptPanel.setSize(500, 380);
String tempFile = "tempBooking.png";
savePanelAsImage(receiptPanel, tempFile);
String imageUrl = uploadImage(tempFile);
if (imageUrl.equals("ERROR")) {
JOptionPane.showMessageDialog(null, "Failed to upload image for QR");
return;
}
String qrFile = "bookingQR.png";
generateQRCode(imageUrl, qrFile);
showImage(qrFile, "Scan QR to view booking image");
} catch (Exception ex) {
ex.printStackTrace();
JOptionPane.showMessageDialog(null, "Error generating QR: " + ex.getMessage());
}
});
// Cancel Booking button
JButton cancelBtn = new JButton("Cancel Booking");
cancelBtn.setBounds(760, 115, 130, 25);
panel.add(cancelBtn);
cancelBtn.addActionListener(e -> {
int confirm = JOptionPane.showConfirmDialog(null,
"Do you really want to cancel this booking?", "Confirm Cancel", JOptionPane.YES_NO_OPTION);
if (confirm != JOptionPane.YES_OPTION) return;
try (Connection con = DB.getConnection()) {
int price = Integer.parseInt(pricePerDay.trim());
// Refund current user (booker)
PreparedStatement ps1 = con.prepareStatement("UPDATE customer SET balance = balance + ? WHERE username = ?");
ps1.setInt(1, price);
ps1.setString(2, bookedBy);
ps1.executeUpdate();
ps1.close();
// Deduct owner
PreparedStatement ps2 = con.prepareStatement("UPDATE customer SET balance = balance - ? WHERE username = ?");
ps2.setInt(1, price);
ps2.setString(2, ownerUsername);
ps2.executeUpdate();
ps2.close();
// Mark booking as available
String[] parts = vehicleName.split(" ", 2);
String brand = parts.length > 0 ? parts[0] : "";
String model = parts.length > 1 ? parts[1] : "";
PreparedStatement ps3 = con.prepareStatement("UPDATE bookings SET booked_by = NULL WHERE brand = ? AND model = ?");
ps3.setString(1, brand);
ps3.setString(2, model);
ps3.executeUpdate();
ps3.close();
bookedByLabel.setText("");
cancelBtn.setEnabled(false);
JOptionPane.showMessageDialog(null, "Booking cancelled successfully.");
} catch (Exception ex) {
ex.printStackTrace();
JOptionPane.showMessageDialog(null, "Error cancelling booking: " + ex.getMessage());
}
});
// Hover effect
Border defaultBorder = BorderFactory.createLineBorder(Color.LIGHT_GRAY);
Border hoverBorder = BorderFactory.createLineBorder(new Color(0, 120, 215), 2);
panel.addMouseListener(new java.awt.event.MouseAdapter() {
@Override
public void mouseEntered(java.awt.event.MouseEvent evt) {
panel.setBackground(new Color(245, 247, 250));
panel.setBorder(hoverBorder);
panel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}
@Override
public void mouseExited(java.awt.event.MouseEvent evt) {
panel.setBackground(Color.WHITE);
panel.setBorder(defaultBorder);
panel.setCursor(Cursor.getDefaultCursor());
}
});
panel.setBorder(defaultBorder);
return panel;
}
static String API_KEY = "310c960267d790e3b5905009b64dd96c";
public static void savePanelAsImage(JPanel panel, String fileName) {
panel.setSize(panel.getPreferredSize());
BufferedImage image = new BufferedImage(panel.getWidth(), panel.getHeight(), BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = image.createGraphics();
g2d.setColor(Color.WHITE); // fill background
g2d.fillRect(0, 0, panel.getWidth(), panel.getHeight());
panel.printAll(g2d); // <-- fixed here
g2d.dispose();
try {
ImageIO.write(image, "png", new File(fileName));
} catch (Exception ex) {
ex.printStackTrace();
}
}
public static String uploadImage(String filePath) {
try {
File file = new File(filePath);
byte[] bytes = Files.readAllBytes(file.toPath());
String encoded = Base64.getEncoder().encodeToString(bytes);
URL url = new URL("https://api.imgbb.com/1/upload?key=" + API_KEY);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoOutput(true);
conn.setRequestMethod("POST");
String data = "image=" + URLEncoder.encode(encoded, "UTF-8");
OutputStream os = conn.getOutputStream();
os.write(data.getBytes());
os.flush();
os.close();
BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
StringBuilder response = new StringBuilder();
String line;
while ((line = in.readLine()) != null) response.append(line);
in.close();
String json = response.toString();
int start = json.indexOf("\"url\":\"") + 7;
int end = json.indexOf("\"", start);
return json.substring(start, end);
} catch (Exception e) { e.printStackTrace(); return "ERROR"; }
}
public static void generateQRCode(String data, String filePath) {
int width = 300, height = 300;
QRCodeWriter qrCodeWriter = new QRCodeWriter();
try {
BitMatrix bitMatrix = qrCodeWriter.encode(data, com.google.zxing.BarcodeFormat.QR_CODE, width, height);
Path path = FileSystems.getDefault().getPath(filePath);
com.google.zxing.client.j2se.MatrixToImageWriter.writeToPath(bitMatrix, "PNG", path);
} catch (Exception e) { e.printStackTrace(); }
}
public static void showImage(String filePath, String title) {
JFrame frame = new JFrame(title);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setSize(350, 350);
JLabel label = new JLabel(new ImageIcon(filePath));
frame.add(label);
frame.setVisible(true);
}
// Updated loadBookings: no filtering by username, display all
public void loadBookings() {
scrollablepanel.removeAll();
final int CARD_HEIGHT = 150;
final int GAP = 10;
int count = 0;
try (Connection con = DB.getConnection()) {
// Only select bookings made by the current user
String query = "SELECT brand, model, location, price_per_day, vehicle_image, created_at, booked_by, username AS owner, " +
"pickup_location, dropoff_location, pickup_date, return_date " +
"FROM bookings WHERE booked_by = ? ORDER BY created_at DESC";
PreparedStatement ps = con.prepareStatement(query);
ps.setString(1, username); // logged-in user's username
ResultSet rs = ps.executeQuery();
while (rs.next()) {
count++;
String pickupLocation = rs.getString("pickup_location");
String dropoffLocation = rs.getString("dropoff_location");
String pickupDate = rs.getString("pickup_date");
String dropoffDate = rs.getString("return_date");
String vehicleName = rs.getString("brand") + " " + rs.getString("model");
byte[] imageBytes = rs.getBytes("vehicle_image");
String location = rs.getString("location");
String createdAt = rs.getString("created_at");
String price = rs.getString("price_per_day");
String owner = rs.getString("owner");
String bookedBy = rs.getString("booked_by");
JPanel card = createBookingPanel(vehicleName, imageBytes, location, createdAt, price, owner, bookedBy,
pickupLocation, dropoffLocation, pickupDate, dropoffDate);
scrollablepanel.add(card);
scrollablepanel.add(Box.createRigidArea(new Dimension(0, GAP)));
}
rs.close();
ps.close();
} catch (Exception e) {
e.printStackTrace();
JOptionPane.showMessageDialog(this, "Error loading bookings: " + e.getMessage());
}
int totalHeight = Math.max(1, count) * (CARD_HEIGHT + GAP) + 20;
int width = jScrollPane1.getViewport().getWidth() > 0 ? jScrollPane1.getViewport().getWidth() : 1000;
scrollablepanel.setPreferredSize(new Dimension(width, totalHeight));
scrollablepanel.revalidate();
scrollablepanel.repaint();
System.out.println("loadBookings -> cards: " + count);
}
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
bottom = new javax.swing.JPanel();
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();
renter = new javax.swing.JLabel();
pfp = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
scrollablepanel = new javax.swing.JPanel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setBackground(new java.awt.Color(255, 255, 255));
bottom.setBackground(new java.awt.Color(204, 204, 204));
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);
}
});
renter.setFont(new java.awt.Font("SansSerif", 1, 18)); // NOI18N
renter.setText("Become a Renter");
renter.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
renter.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
renterMouseClicked(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)
.addGroup(whitepanelLayout.createSequentialGroup()
.addGap(6, 6, 6)
.addComponent(jLabel2))
.addComponent(jLabel1))
.addGap(192, 192, 192)
.addComponent(homee)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(renter)
.addGap(80, 80, 80)
.addComponent(pfp, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(26, 26, 26))
);
whitepanelLayout.setVerticalGroup(
whitepanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.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)
.addComponent(RR_logo, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(whitepanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(pfp, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, 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))))
.addGap(24, 24, 24))
.addGroup(whitepanelLayout.createSequentialGroup()
.addGap(15, 15, 15)
.addGroup(whitepanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(homee, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(renter))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
javax.swing.GroupLayout scrollablepanelLayout = new javax.swing.GroupLayout(scrollablepanel);
scrollablepanel.setLayout(scrollablepanelLayout);
scrollablepanelLayout.setHorizontalGroup(
scrollablepanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 1359, Short.MAX_VALUE)
);
scrollablepanelLayout.setVerticalGroup(
scrollablepanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 641, Short.MAX_VALUE)
);
jScrollPane1.setViewportView(scrollablepanel);
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()
.addContainerGap()
.addComponent(jScrollPane1)
.addContainerGap())
);
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)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 643, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(18, Short.MAX_VALUE))
);
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 renterMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_renterMouseClicked
try {
// ✅ Pass booking details AND username to dashboard
RenterDashBoard renter = new RenterDashBoard(
this.username
);
this.dispose();
renter.setVisible(true);
} catch (Exception ex) {
ex.printStackTrace();
StylishPopup.showError(this, "Error: " + ex.getMessage());
}
}//GEN-LAST:event_renterMouseClicked
private void homeeMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_homeeMouseClicked
Primary_Screen_Logged primary = new Primary_Screen_Logged(this.username);
primary.setVisible(true);
this.dispose();
}//GEN-LAST:event_homeeMouseClicked
private void jLabel1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel1MouseClicked
this.dispose();
new your_bookings().setVisible(true);
}//GEN-LAST:event_jLabel1MouseClicked
/**
* @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 your_bookings().setVisible(true));
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel RR_logo;
private javax.swing.JPanel bottom;
private javax.swing.JLabel homee;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JLabel pfp;
private javax.swing.JLabel renter;
private javax.swing.JPanel scrollablepanel;
private javax.swing.JPanel whitepanel;
// End of variables declaration//GEN-END:variables
}