commit a30d3776332f27ad7f5f8c9a7013fcea4155cd7e
parent f6ed298e41097567d9fd90c5e741817c63fe9e62
Author: adglas21 <adamglasheen99@gmail.com>
Date: Sun, 10 Nov 2024 11:19:51 +0000
StartPanel.java implemented
Diffstat:
3 files changed, 59 insertions(+), 6 deletions(-)
diff --git a/TicTacToeClient/src/main/java/com/groupproject/tictactoeclient/ContentPanes/StartPanel.java b/TicTacToeClient/src/main/java/com/groupproject/tictactoeclient/ContentPanes/StartPanel.java
@@ -9,6 +9,7 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JPanel;
+import javax.swing.SpringLayout;
/**
*
@@ -16,13 +17,42 @@ import javax.swing.JPanel;
*/
public class StartPanel extends JPanel{
public StartPanel(TicTacToeClient client) {
- JButton startButton = new JButton("Start");
- add(startButton);
- startButton.addActionListener(new ActionListener() {
+ // Set panel layout to spring layout
+ SpringLayout layout = new SpringLayout();
+ setLayout(layout);
+
+ //Create the 2 buttons login and register
+ JButton loginButton = new JButton("Login");
+ JButton registerButton = new JButton("Register");
+
+ //Add the Buttons to the panel
+ add(loginButton);
+ add(registerButton);
+
+ //Login Button constraints
+ layout.putConstraint(SpringLayout.HORIZONTAL_CENTER, loginButton, -60, SpringLayout.HORIZONTAL_CENTER, this);
+ layout.putConstraint(SpringLayout.VERTICAL_CENTER, loginButton, 0, SpringLayout.VERTICAL_CENTER, this);
+
+ //Register Button constraints
+ layout.putConstraint(SpringLayout.WEST, registerButton, 10, SpringLayout.EAST, loginButton);
+ layout.putConstraint(SpringLayout.VERTICAL_CENTER, registerButton, 0, SpringLayout.VERTICAL_CENTER, this);
+
+
+
+ //Login Button Action - go to login page
+ loginButton.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ client.showPanel(new login(client));
+ }
+ });
+
+ //Register Button Action - go to the register page
+ registerButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
- client.showPanel(new MainContentPanel(client));
+ client.showPanel(new register(client));
}
});
}
diff --git a/TicTacToeClient/src/main/java/com/groupproject/tictactoeclient/ContentPanes/login.java b/TicTacToeClient/src/main/java/com/groupproject/tictactoeclient/ContentPanes/login.java
@@ -0,0 +1,23 @@
+/*
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
+ */
+package com.groupproject.tictactoeclient.ContentPanes;
+import com.groupproject.tictactoeclient.TicTacToeClient;
+import javax.swing.JButton;
+import javax.swing.JLabel;
+import javax.swing.JList;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.SpringLayout;
+/**
+ *
+ * @author adam
+ */
+public class login extends JPanel {
+ public login(TicTacToeClient client) {
+
+
+
+ }
+}
diff --git a/TicTacToeClient/src/main/java/com/groupproject/tictactoeclient/TicTacToeClient.java b/TicTacToeClient/src/main/java/com/groupproject/tictactoeclient/TicTacToeClient.java
@@ -49,8 +49,8 @@ public class TicTacToeClient {
frame = new JFrame("TicTacToe"); // Create new Swing window
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(600, 400);
- showPanel(new register(this));
- //showPanel(new StartPanel(this));
+ //showPanel(new register(this));
+ showPanel(new StartPanel(this));
frame.setVisible(true);
}