Skip to content
Snippets Groups Projects
Commit 4f8b919a authored by Hai HoDac's avatar Hai HoDac
Browse files

update startScreen

parent ad7174e1
No related branches found
No related tags found
1 merge request!35update startScreen
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
</constraints> </constraints>
<properties> <properties>
<editable value="false"/> <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> </properties>
</component> </component>
</children> </children>
...@@ -74,17 +74,22 @@ ...@@ -74,17 +74,22 @@
</properties> </properties>
<border type="none" title=" "/> <border type="none" title=" "/>
<children> <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"> <component id="94078" class="javax.swing.JLabel">
<constraints> <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> </constraints>
<properties> <properties>
<text value="Server IP:"/> <text value="Server IP:"/>
</properties> </properties>
</component> </component>
<component id="63209" class="javax.swing.JTextField" binding="textField2"> <component id="63209" class="javax.swing.JTextField" binding="serverField">
<constraints> <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"/> <preferred-size width="150" height="-1"/>
</grid> </grid>
</constraints> </constraints>
...@@ -92,43 +97,38 @@ ...@@ -92,43 +97,38 @@
<text value=""/> <text value=""/>
</properties> </properties>
</component> </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"> <component id="87b91" class="javax.swing.JLabel">
<constraints> <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> </constraints>
<properties> <properties>
<text value="Your name:"/> <text value="Username:"/>
</properties> </properties>
</component> </component>
<component id="e39f4" class="javax.swing.JTextField" binding="textField1" default-binding="true"> <component id="e39f4" class="javax.swing.JTextField" binding="usernameField">
<constraints> <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"/> <preferred-size width="150" height="-1"/>
</grid> </grid>
</constraints> </constraints>
<properties/> <properties/>
</component> </component>
<component id="51d9f" class="javax.swing.JPasswordField" binding="passwordField"> <component id="62e48" class="javax.swing.JLabel">
<constraints> <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"> <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"/>
<preferred-size width="150" height="-1"/>
</grid>
</constraints> </constraints>
<properties> <properties>
<columns value="20"/> <text value="Password:"/>
</properties> </properties>
</component> </component>
<component id="62e48" class="javax.swing.JLabel"> <component id="51d9f" class="javax.swing.JPasswordField" binding="passwordField">
<constraints> <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> </constraints>
<properties> <properties>
<text value="Password:"/> <columns value="20"/>
</properties> </properties>
</component> </component>
</children> </children>
......
...@@ -2,17 +2,21 @@ package GUI; ...@@ -2,17 +2,21 @@ package GUI;
import client.Client; import client.Client;
import javax.imageio.ImageIO;
import javax.swing.*; import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;
public class StartScreen { public class StartScreen {
private JTextPane information; private JTextPane information;
private JPanel panel1; private JPanel panel1;
private JTextField textField1; private JTextField usernameField;
private JButton joinButton; private JButton joinButton;
private JTextField textField2; private JTextField serverField;
private JTextField textField3; private JTextField textField3;
private JPasswordField passwordField; private JPasswordField passwordField;
JFrame frame; JFrame frame;
...@@ -35,8 +39,8 @@ public class StartScreen { ...@@ -35,8 +39,8 @@ public class StartScreen {
{ {
if (e.getSource() == joinButton) if (e.getSource() == joinButton)
{ {
String serverAddress = textField2.getText(); String serverAddress = serverField.getText();
String userName = textField1.getText(); String userName = usernameField.getText();
String password = new String(passwordField.getPassword()); String password = new String(passwordField.getPassword());
int connectionStatus = client.connect(userName, serverAddress, password); int connectionStatus = client.connect(userName, serverAddress, password);
...@@ -49,7 +53,7 @@ public class StartScreen { ...@@ -49,7 +53,7 @@ public class StartScreen {
} }
else if( connectionStatus == 2 ) else if( connectionStatus == 2 )
{ {
showErrorMessage("Duplicate username: Please enter a new username"); showErrorMessage("Duplicate usernameField: Please enter a new usernameField");
} }
else if( connectionStatus == 3 ) else if( connectionStatus == 3 )
{ {
...@@ -84,6 +88,29 @@ public class StartScreen { ...@@ -84,6 +88,29 @@ public class StartScreen {
frame.setLocationRelativeTo(null); frame.setLocationRelativeTo(null);
frame.getRootPane().setDefaultButton(joinButton); frame.getRootPane().setDefaultButton(joinButton);
joinButton.requestFocus(); joinButton.requestFocus();
//frame.getContentPane().add(new JPanelWithBackground("sample.jpeg"));
frame.setVisible(true); 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);
// }
// }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment