- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGuideProfilePage.java
More file actions
Latest commit
139 lines (112 loc) · 5.38 KB
/
Copy pathGuideProfilePage.java
File metadata and controls
139 lines (112 loc) · 5.38 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
importjavax.swing.*;
importjava.awt.*;
publicclassGuideProfilePageextendsJPanel {
privateStringusername;
privateMainFramemainFrame;
publicGuideProfilePage(MainFramemainFrame, String[] userInfo) {
this.mainFrame = mainFrame;
this.username = userInfo[3]; // Assuming username is the 4th field (index 3)
setLayout(newBorderLayout());
// Set the background image
ImageIconbackgroundImageIcon = newImageIcon("profile-bg.jpg"); // Replace with your image file
ImagebackgroundImage = backgroundImageIcon.getImage();
BackgroundPanelbackgroundPanel = newBackgroundPanel(backgroundImage);
// Create a panel to hold the profile information
JPanelprofilePanel = newJPanel();
profilePanel.setBackground(newColor(255, 255, 224, 200)); // Light yellow with transparency
profilePanel.setLayout(newGridBagLayout());
GridBagConstraintsgbc = newGridBagConstraints();
gbc.insets = newInsets(10, 20, 10, 20);
gbc.anchor = GridBagConstraints.CENTER;
// Title Label
JLabeltitleLabel = newJLabel("Guide Dashboard", SwingConstants.CENTER);
titleLabel.setFont(newFont("Arial", Font.BOLD, 32));
titleLabel.setForeground(Color.BLACK); // Set text color to black
gbc.gridx = 0;
gbc.gridy = 0;
gbc.gridwidth = 2;
profilePanel.add(titleLabel, gbc);
gbc.gridwidth = 1;
gbc.anchor = GridBagConstraints.WEST;
gbc.fill = GridBagConstraints.NONE;
// Display user information
gbc.gridy++;
addLabelAndValue(profilePanel, gbc, "Name:", userInfo[0]);
gbc.gridy++;
addLabelAndValue(profilePanel, gbc, "Phone Number:", userInfo[1]);
gbc.gridy++;
addLabelAndValue(profilePanel, gbc, "Email:", userInfo[2]);
gbc.gridy++;
addLabelAndValue(profilePanel, gbc, "Username:", userInfo[3]);
gbc.gridy++;
addLabelAndValue(profilePanel, gbc, "Address:", userInfo[5]); // Adjust index if necessary
// Buttons Panel
gbc.gridy++;
gbc.gridx = 0;
gbc.gridwidth = 2;
gbc.anchor = GridBagConstraints.CENTER;
JPanelbuttonPanel = newJPanel(newFlowLayout(FlowLayout.CENTER, 20, 10));
buttonPanel.setOpaque(false);
JButtonchangePasswordButton = newJButton("Change Password");
styleButton(changePasswordButton);
changePasswordButton.addActionListener(e -> mainFrame.showChangePasswordPage(this.username, "GuidesData.txt", "Guide"));
buttonPanel.add(changePasswordButton);
JButtonseeBookingsButton = newJButton("See Booking by Travelers");
styleButton(seeBookingsButton);
seeBookingsButton.addActionListener(e -> mainFrame.showSeeBookingGuidePage(this.username));
buttonPanel.add(seeBookingsButton);
JButtonlogoutButton = newJButton("Log Out");
styleButton(logoutButton);
logoutButton.addActionListener(e -> mainFrame.showPage("LoginPage"));
buttonPanel.add(logoutButton);
profilePanel.add(buttonPanel, gbc);
// Add profilePanel to backgroundPanel
backgroundPanel.add(profilePanel);
// Add backgroundPanel to the main panel
add(backgroundPanel, BorderLayout.CENTER);
}
privatevoidaddLabelAndValue(JPanelpanel, GridBagConstraintsgbc, StringlabelText, StringvalueText) {
JLabellabel = newJLabel(labelText);
label.setFont(newFont("Arial", Font.BOLD, 18));
label.setForeground(Color.BLACK); // Set text color to black
gbc.gridx = 0;
panel.add(label, gbc);
JLabelvalue = newJLabel(valueText);
value.setFont(newFont("Arial", Font.PLAIN, 18));
value.setForeground(Color.BLACK); // Set text color to black
gbc.gridx = 1;
panel.add(value, gbc);
}
privatevoidstyleButton(JButtonbutton) {
button.setFont(newFont("Arial", Font.BOLD, 16));
button.setForeground(Color.WHITE);
button.setBackground(newColor(64, 64, 64)); // Dark gray color
button.setFocusPainted(false);
button.setBorderPainted(false);
button.setOpaque(true);
button.setCursor(newCursor(Cursor.HAND_CURSOR));
// Add mouse hover effect
button.addMouseListener(newjava.awt.event.MouseAdapter() {
publicvoidmouseEntered(java.awt.event.MouseEventevt) {
button.setBackground(newColor(255, 204, 0)); // Yellow color on hover
}
publicvoidmouseExited(java.awt.event.MouseEventevt) {
button.setBackground(newColor(64, 64, 64)); // Original color
}
});
}
// Custom JPanel to draw the background image
classBackgroundPanelextendsJPanel {
privateImagebackgroundImage;
publicBackgroundPanel(ImagebackgroundImage) {
this.backgroundImage = backgroundImage;
setLayout(newGridBagLayout()); // Center the profile panel
}
@Override
protectedvoidpaintComponent(Graphicsg) {
super.paintComponent(g);
// Draw the background image scaled to fit the panel
g.drawImage(backgroundImage, 0, 0, getWidth(), getHeight(), this);
}
}
}