Online-TicTacToe

Log | Files | Refs | README | LICENSE

commit f6ed298e41097567d9fd90c5e741817c63fe9e62
parent 03d7049a31e16be9ac39f76bc32871bb94908700
Author: lukeeeeeee334 <lukeosullivan123@gmail.com>
Date:   Sat,  9 Nov 2024 16:32:13 +0000

register.java and client change

made the register.java file and changed the client file so that when you run it it brings you to the register panel then to the start then to the  maincontent.java panel

Diffstat:
ATicTacToeClient/src/main/java/com/groupproject/tictactoeclient/ContentPanes/register.java | 55+++++++++++++++++++++++++++++++++++++++++++++++++++++++
MTicTacToeClient/src/main/java/com/groupproject/tictactoeclient/TicTacToeClient.java | 5+++--
2 files changed, 58 insertions(+), 2 deletions(-)

diff --git a/TicTacToeClient/src/main/java/com/groupproject/tictactoeclient/ContentPanes/register.java b/TicTacToeClient/src/main/java/com/groupproject/tictactoeclient/ContentPanes/register.java @@ -0,0 +1,55 @@ +package com.groupproject.tictactoeclient.ContentPanes; + +import com.groupproject.tictactoeclient.TicTacToeClient; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.BoxLayout; +import java.awt.FlowLayout; +import javax.swing.JButton; +import javax.swing.JPanel; +import javax.swing.JLabel; +import javax.swing.JTextField; +import javax.swing.Box; + +/** + * + * Author: Willi + */ +public class register extends JPanel { + public register(TicTacToeClient client) { + // Set the layout to BoxLayout for vertical alignment + setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); + + // Username label and very small text field +JPanel usernamePanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0)); + JLabel usernameLabel = new JLabel("Username:"); + JTextField usernameField = new JTextField(15); + usernameField.setPreferredSize(new Dimension(600, 20)); + usernamePanel.add(usernameLabel); + usernamePanel.add(usernameField); + add(usernamePanel); + + // Password label and very small text field + JPanel passwordPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0)); + JLabel passwordLabel = new JLabel("Password:"); + JTextField passwordField = new JTextField(15); + passwordField.setMaximumSize(new Dimension(600, 20)); // Forces small width + passwordPanel.add(passwordLabel); + passwordPanel.add(passwordField); + add(passwordPanel); + + // Register button + JButton registerButton = new JButton("Register"); + add(Box.createVerticalStrut(10)); // Add space between fields and button + add(registerButton); + + // Action listener for register button + registerButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + client.showPanel(new StartPanel(client)); + } + }); + } +} diff --git a/TicTacToeClient/src/main/java/com/groupproject/tictactoeclient/TicTacToeClient.java b/TicTacToeClient/src/main/java/com/groupproject/tictactoeclient/TicTacToeClient.java @@ -7,6 +7,7 @@ package com.groupproject.tictactoeclient; import com.formdev.flatlaf.FlatDarkLaf; import com.groupproject.tictactoeclient.ContentPanes.MainContentPanel; import com.groupproject.tictactoeclient.ContentPanes.StartPanel; +import com.groupproject.tictactoeclient.ContentPanes.register; import com.tttws.TicTacToeWS; import com.tttws.TicTacToeWebService; import javax.swing.JFrame; @@ -48,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 StartPanel(this)); + showPanel(new register(this)); + //showPanel(new StartPanel(this)); frame.setVisible(true); }