Online-TicTacToe

Log | Files | Refs | README | LICENSE

commit 48372f788c274cbd1e059ac706c7122944cff194
parent a30d3776332f27ad7f5f8c9a7013fcea4155cd7e
Author: adglas21 <adamglasheen99@gmail.com>
Date:   Sun, 10 Nov 2024 12:33:50 +0000

login.java layout complete

Diffstat:
MTicTacToeClient/src/main/java/com/groupproject/tictactoeclient/ContentPanes/StartPanel.java | 2+-
MTicTacToeClient/src/main/java/com/groupproject/tictactoeclient/ContentPanes/login.java | 70++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------
2 files changed, 65 insertions(+), 7 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 @@ -13,7 +13,7 @@ import javax.swing.SpringLayout; /** * - * @author Willi + * @author Adam */ public class StartPanel extends JPanel{ public StartPanel(TicTacToeClient 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 @@ -4,12 +4,10 @@ */ 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; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.*; /** * * @author adam @@ -17,6 +15,66 @@ import javax.swing.SpringLayout; public class login extends JPanel { public login(TicTacToeClient client) { + // Set panel layout to spring layout + SpringLayout layout = new SpringLayout(); + setLayout(layout); + + //Create the login Button + JButton loginButton = new JButton("Login"); + + //Create the username and password Labels + JLabel usernameLabel = new JLabel("username"); + JLabel passwordLabel = new JLabel("password"); + + //Create the username and password text fields + JTextField usernameTextField = new JTextField(); + JTextField passwordTextField = new JTextField(); + + //Create a checkbox to show the password + JCheckBox showPassword = new JCheckBox("show password"); + + add(loginButton); + add(usernameLabel); + add(passwordLabel); + add(usernameTextField); + add(passwordTextField); + add(showPassword); + + + // UsernameLabel constraints + layout.putConstraint(SpringLayout.EAST, usernameLabel, -20, SpringLayout.WEST, usernameTextField); + layout.putConstraint(SpringLayout.VERTICAL_CENTER, usernameLabel, 0, SpringLayout.VERTICAL_CENTER, usernameTextField); + + //Username textfield Constraint + layout.putConstraint(SpringLayout.HORIZONTAL_CENTER, usernameTextField, 0, SpringLayout.HORIZONTAL_CENTER, this); + layout.putConstraint(SpringLayout.VERTICAL_CENTER, usernameTextField, 0, SpringLayout.VERTICAL_CENTER, this); + + //PasswordLabel constraints + layout.putConstraint(SpringLayout.EAST, passwordLabel, -20, SpringLayout.WEST, passwordTextField); + layout.putConstraint(SpringLayout.VERTICAL_CENTER, passwordLabel, 0, SpringLayout.VERTICAL_CENTER, passwordTextField); + + //Password textfield constraint + layout.putConstraint(SpringLayout.HORIZONTAL_CENTER, passwordTextField, 0, SpringLayout.HORIZONTAL_CENTER, this); + layout.putConstraint(SpringLayout.NORTH, passwordTextField, 20, SpringLayout.SOUTH, usernameTextField); + + //Show password checkbox constraint + layout.putConstraint(SpringLayout.HORIZONTAL_CENTER, showPassword, 0, SpringLayout.HORIZONTAL_CENTER, this); + layout.putConstraint(SpringLayout.NORTH, showPassword, 20, SpringLayout.SOUTH, passwordTextField); + + //Login Button constraint + layout.putConstraint(SpringLayout.HORIZONTAL_CENTER, loginButton, 0, SpringLayout.HORIZONTAL_CENTER, this); + layout.putConstraint(SpringLayout.NORTH, loginButton, 20, SpringLayout.SOUTH, showPassword); + + + +// //Login Button Action - check the entries of the textFields +// loginButton.addActionListener(new ActionListener() { +// @Override +// public void actionPerformed(ActionEvent e) { +// client.showPanel(new login(client)); +// } +// }); + }