aboutsummaryrefslogtreecommitdiff
path: root/src/UI/Components/LoginPanel.java
diff options
context:
space:
mode:
authorVidhu Kant Sharma <vidhukant@vidhukant.com>2024-11-16 02:11:24 +0530
committerVidhu Kant Sharma <vidhukant@vidhukant.com>2024-11-16 02:11:24 +0530
commited3e023d1da3465bc79a91d38950a167004911b2 (patch)
tree08fb4de9af501612ccb85c8ee2f6beb60779c1f2 /src/UI/Components/LoginPanel.java
First Commit
Diffstat (limited to 'src/UI/Components/LoginPanel.java')
-rw-r--r--src/UI/Components/LoginPanel.java55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/UI/Components/LoginPanel.java b/src/UI/Components/LoginPanel.java
new file mode 100644
index 0000000..e79326b
--- /dev/null
+++ b/src/UI/Components/LoginPanel.java
@@ -0,0 +1,55 @@
+package UI.Components;
+
+import UI.MainWindow;
+import UI.SettingsPopupWindow;
+
+import javax.swing.*;
+import javax.swing.border.EmptyBorder;
+import java.awt.*;
+
+public class LoginPanel extends JPanel {
+ public JButton loginButton;
+ private SettingsPopupWindow settingsPopupWindow;
+
+ public InputBox usernameInput;
+ public InputBox passwordInput;
+
+ public LoginPanel() {
+ usernameInput = new InputBox("Username:");
+ usernameInput.setBorder(new EmptyBorder(140, 100, 0, 100));
+ this.add(usernameInput);
+
+ passwordInput = new InputBox("Password:");
+ passwordInput.setBorder(new EmptyBorder(10, 100, 10, 100));
+ this.add(passwordInput);
+
+ JPanel buttonPanel = new JPanel();
+ buttonPanel.add(Box.createRigidArea(new Dimension(140, 0)));
+
+ JButton settingsButton = new JButton("Settings");
+ settingsButton.addActionListener(_ -> {
+ if (settingsPopupWindow == null) {
+ settingsPopupWindow = new SettingsPopupWindow();
+ settingsPopupWindow.saveButton.addActionListener(_ -> {
+ MainWindow.url = settingsPopupWindow.hostnameInput.getValue();
+ settingsPopupWindow.setVisible(false);
+ });
+ }
+
+ settingsPopupWindow.hostnameInput.setValue(MainWindow.url);
+
+ settingsPopupWindow.setVisible(true);
+ });
+ buttonPanel.add(settingsButton);
+
+ buttonPanel.add(Box.createRigidArea(new Dimension(10, 0)));
+
+ loginButton = new JButton("Login");
+ buttonPanel.add(loginButton);
+
+ buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
+ this.add(buttonPanel);
+
+ this.setMaximumSize(new Dimension(350, 200));
+ }
+}