From 4f8b919aa730067d21a3bc6ec29ad19daad4903d Mon Sep 17 00:00:00 2001
From: Hai HoDac <hhodac@student.unimelb.edu.au>
Date: Wed, 23 Oct 2019 20:03:56 +1100
Subject: [PATCH] update startScreen
---
src/GUI/StartScreen.form | 42 ++++++++++++++++++++--------------------
src/GUI/StartScreen.java | 37 ++++++++++++++++++++++++++++++-----
2 files changed, 53 insertions(+), 26 deletions(-)
diff --git a/src/GUI/StartScreen.form b/src/GUI/StartScreen.form
index a6eacb7..f348817 100644
--- a/src/GUI/StartScreen.form
+++ b/src/GUI/StartScreen.form
@@ -40,7 +40,7 @@
</constraints>
<properties>
<editable value="false"/>
- <text value="Welcome to Distributed Whiteboard. Please provide server's IP, username, and password."/>
+ <text value="Please provide your username and password, as well as server's IP to start."/>
</properties>
</component>
</children>
@@ -74,17 +74,22 @@
</properties>
<border type="none" title=" "/>
<children>
+ <vspacer id="bb71b">
+ <constraints>
+ <grid row="0" column="2" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
+ </constraints>
+ </vspacer>
<component id="94078" class="javax.swing.JLabel">
<constraints>
- <grid row="0" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
+ <grid row="2" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Server IP:"/>
</properties>
</component>
- <component id="63209" class="javax.swing.JTextField" binding="textField2">
+ <component id="63209" class="javax.swing.JTextField" binding="serverField">
<constraints>
- <grid row="1" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
+ <grid row="3" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
@@ -92,43 +97,38 @@
<text value=""/>
</properties>
</component>
- <vspacer id="bb71b">
- <constraints>
- <grid row="0" column="2" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
- </constraints>
- </vspacer>
<component id="87b91" class="javax.swing.JLabel">
<constraints>
- <grid row="0" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
+ <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
- <text value="Your name:"/>
+ <text value="Username:"/>
</properties>
</component>
- <component id="e39f4" class="javax.swing.JTextField" binding="textField1" default-binding="true">
+ <component id="e39f4" class="javax.swing.JTextField" binding="usernameField">
<constraints>
- <grid row="1" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
+ <grid row="1" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
- <component id="51d9f" class="javax.swing.JPasswordField" binding="passwordField">
+ <component id="62e48" class="javax.swing.JLabel">
<constraints>
- <grid row="3" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
- <preferred-size width="150" height="-1"/>
- </grid>
+ <grid row="0" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
- <columns value="20"/>
+ <text value="Password:"/>
</properties>
</component>
- <component id="62e48" class="javax.swing.JLabel">
+ <component id="51d9f" class="javax.swing.JPasswordField" binding="passwordField">
<constraints>
- <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
+ <grid row="1" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
+ <preferred-size width="150" height="-1"/>
+ </grid>
</constraints>
<properties>
- <text value="Password:"/>
+ <columns value="20"/>
</properties>
</component>
</children>
diff --git a/src/GUI/StartScreen.java b/src/GUI/StartScreen.java
index 70ac2f2..9494617 100644
--- a/src/GUI/StartScreen.java
+++ b/src/GUI/StartScreen.java
@@ -2,17 +2,21 @@ package GUI;
import client.Client;
+import javax.imageio.ImageIO;
import javax.swing.*;
+import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.io.File;
+import java.io.IOException;
public class StartScreen {
private JTextPane information;
private JPanel panel1;
- private JTextField textField1;
+ private JTextField usernameField;
private JButton joinButton;
- private JTextField textField2;
+ private JTextField serverField;
private JTextField textField3;
private JPasswordField passwordField;
JFrame frame;
@@ -35,8 +39,8 @@ public class StartScreen {
{
if (e.getSource() == joinButton)
{
- String serverAddress = textField2.getText();
- String userName = textField1.getText();
+ String serverAddress = serverField.getText();
+ String userName = usernameField.getText();
String password = new String(passwordField.getPassword());
int connectionStatus = client.connect(userName, serverAddress, password);
@@ -49,7 +53,7 @@ public class StartScreen {
}
else if( connectionStatus == 2 )
{
- showErrorMessage("Duplicate username: Please enter a new username");
+ showErrorMessage("Duplicate usernameField: Please enter a new usernameField");
}
else if( connectionStatus == 3 )
{
@@ -84,6 +88,29 @@ public class StartScreen {
frame.setLocationRelativeTo(null);
frame.getRootPane().setDefaultButton(joinButton);
joinButton.requestFocus();
+
+ //frame.getContentPane().add(new JPanelWithBackground("sample.jpeg"));
frame.setVisible(true);
}
+
+// public class JPanelWithBackground extends JPanel
+// {
+//
+// private Image backgroundImage;
+//
+// // Some code to initialize the background image.
+// // Here, we use the constructor to load the image. This
+// // can vary depending on the use case of the panel.
+// public JPanelWithBackground(String fileName) throws IOException
+// {
+// backgroundImage = ImageIO.read(new File(fileName));
+// }
+//
+// public void paintComponent(Graphics g) {
+// super.paintComponent(g);
+//
+// // Draw the background image.
+// g.drawImage(backgroundImage, 0, 0, this);
+// }
+// }
}
--
GitLab