-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathusersettings.java
More file actions
44 lines (35 loc) · 1.77 KB
/
Copy pathusersettings.java
File metadata and controls
44 lines (35 loc) · 1.77 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
public class SettingsPanel extends JPanel {
private JTextField emailField;
private JPasswordField passwordField;
private JCheckBox notificationCheckBox;
public SettingsPanel() {
setLayout(new BorderLayout());
JLabel settingsLabel = new JLabel("Account Settings", JLabel.CENTER);
settingsLabel.setFont(new Font("Arial", Font.BOLD, 20));
add(settingsLabel, BorderLayout.NORTH);
JPanel formPanel = new JPanel(new GridLayout(0, 2));
formPanel.add(new JLabel("Email:"));
emailField = new JTextField();
formPanel.add(emailField);
formPanel.add(new JLabel("Password:"));
passwordField = new JPasswordField();
formPanel.add(passwordField);
formPanel.add(new JLabel("Enable Notifications:"));
notificationCheckBox = new JCheckBox();
formPanel.add(notificationCheckBox);
JButton updateButton = new JButton("Update Settings");
updateButton.addActionListener(e -> updateSettings());
formPanel.add(updateButton);
add(formPanel, BorderLayout.CENTER);
JButton backButton = new JButton("Back to Dashboard");
backButton.addActionListener(e -> MainApp.cardLayout.show(MainApp.mainPanel, "Dashboard"));
add(backButton, BorderLayout.SOUTH);
}
private void updateSettings() {
String email = emailField.getText();
String password = new String(passwordField.getPassword());
boolean notificationsEnabled = notificationCheckBox.isSelected();
// Placeholder for actual update logic
System.out.println("Settings updated: " + email + ", " + (notificationsEnabled ? "Notifications Enabled" : "Notifications Disabled"));
}
}