Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Stephen
IF3230-Tugas-Besar-Sister-2015
Commits
d5600142
Commit
d5600142
authored
Apr 22, 2015
by
Stephen
Browse files
Added sendfind in server
parents
fbfd7708
7c351592
Changes
28
Hide whitespace changes
Inline
Side-by-side
src/client/build/classes/tcpclient/LoginPage.class
deleted
100644 → 0
View file @
fbfd7708
File deleted
src/client/build/classes/tcpclient/TCPClient.class
View file @
d5600142
No preview for this file type
src/client/nbproject/private/private.properties
View file @
d5600142
compile.on.save
=
true
user.properties.file
=
C:
\\
Users
\\
Stephen
\\
AppData
\\
Roaming
\\
NetBeans
\\
8.0.2
\\
build.properties
<<<<<<<
HEAD
=
======
<<<<<<<
HEAD
<<<<<<<
HEAD
user.properties.file
=
C:
\\
Users
\\
user
\\
AppData
\\
Roaming
\\
NetBeans
\\
8.0
\\
build.properties
=======
<<<<<<<
HEAD
=
======
>>>>>>>
2e2ad538abfe623e38cc24be02c48f5ad2ee0768
user.properties.file
=
C:
\\
Users
\\
susanti_2
\\
AppData
\\
Roaming
\\
NetBeans
\\
8.0.2
\\
build.properties
>>>>>>>
43e41c8c08f84039568ca701a584f38f9911e548
=
======
<<<<<<<
HEAD
user.properties.file
=
C:
\\
Users
\\
susanti_2
\\
AppData
\\
Roaming
\\
NetBeans
\\
8.0.2
\\
build.properties
=======
user.properties.file
=
C:
\\
Users
\\
susanti_2
\\
AppData
\\
Roaming
\\
NetBeans
\\
8.0.2
\\
build.properties
>>>>>>>
f5cc2615451f416ad94e5b85c35aa84513a123d3
>>>>>>>
9b3bab9e9eefddca873933beff1cff411b869149
>>>>>>>
4425b3f14619792ceebdcdb264cb7c61d1d9d38c
=
======
>>>>>>>
7d12ee92a34d06c0f223c1804ac375528b1b069d
src/client/nbproject/private/private.xml
View file @
d5600142
...
...
@@ -3,9 +3,15 @@
<editor-bookmarks
xmlns=
"http://www.netbeans.org/ns/editor-bookmarks/2"
lastBookmarkId=
"0"
/>
<open-files
xmlns=
"http://www.netbeans.org/ns/projectui-open-files/2"
>
<group>
<<<<<<
< HEAD
<file
>
file:/C:/Users/susanti_2/Documents/ITB/IF/netbeans/IF3230-Tugas-Besar-Sister-2015/src/client/src/tcpclient/MapTableModel.java
</file>
<file>
file:/C:/Users/susanti_2/Documents/ITB/IF/netbeans/IF3230-Tugas-Besar-Sister-2015/src/client/src/tcpclient/MainPage.java
</file>
<file>
file:/C:/Users/susanti_2/Documents/ITB/IF/netbeans/IF3230-Tugas-Besar-Sister-2015/src/client/src/tcpclient/TCPClient.java
</file>
=======
<file>
file:/C:/Users/Stephen/Documents/NetBeansProjects/TubesSister/src/client/src/tcpclient/MainPage.java
</file>
<file>
file:/C:/Users/Stephen/Documents/NetBeansProjects/TubesSister/src/client/src/tcpclient/TCPClient.java
</file>
<file>
file:/C:/Users/Stephen/Documents/NetBeansProjects/TubesSister/src/client/src/tcpclient/LoginPage.java
</file>
>>>>>>> 7d12ee92a34d06c0f223c1804ac375528b1b069d
</group>
</open-files>
</project-private>
src/client/src/tcpclient/LoginPage.form
deleted
100644 → 0
View file @
fbfd7708
<?xml version="1.0" encoding="UTF-8" ?>
<Form
version=
"1.9"
maxVersion=
"1.9"
type=
"org.netbeans.modules.form.forminfo.JFrameFormInfo"
>
<Properties>
<Property
name=
"defaultCloseOperation"
type=
"int"
value=
"3"
/>
<Property
name=
"title"
type=
"java.lang.String"
value=
"Login/Register"
/>
<Property
name=
"background"
type=
"java.awt.Color"
editor=
"org.netbeans.beaninfo.editors.ColorEditor"
>
<Color
blue=
"ff"
green=
"cc"
red=
"99"
type=
"rgb"
/>
</Property>
<Property
name=
"cursor"
type=
"java.awt.Cursor"
editor=
"org.netbeans.modules.form.editors2.CursorEditor"
>
<Color
id=
"Default Cursor"
/>
</Property>
<Property
name=
"font"
type=
"java.awt.Font"
editor=
"org.netbeans.beaninfo.editors.FontEditor"
>
<Font
name=
"FISHfingers"
size=
"10"
style=
"0"
/>
</Property>
<Property
name=
"foreground"
type=
"java.awt.Color"
editor=
"org.netbeans.beaninfo.editors.ColorEditor"
>
<Color
blue=
"ff"
green=
"99"
red=
"99"
type=
"rgb"
/>
</Property>
<Property
name=
"locationByPlatform"
type=
"boolean"
value=
"true"
/>
<Property
name=
"minimumSize"
type=
"java.awt.Dimension"
editor=
"org.netbeans.beaninfo.editors.DimensionEditor"
>
<Dimension
value=
"[400, 300]"
/>
</Property>
<Property
name=
"name"
type=
"java.lang.String"
value=
"loginFrame"
noResource=
"true"
/>
<Property
name=
"resizable"
type=
"boolean"
value=
"false"
/>
</Properties>
<SyntheticProperties>
<SyntheticProperty
name=
"formSizePolicy"
type=
"int"
value=
"1"
/>
<SyntheticProperty
name=
"generateCenter"
type=
"boolean"
value=
"false"
/>
</SyntheticProperties>
<AuxValues>
<AuxValue
name=
"FormSettings_autoResourcing"
type=
"java.lang.Integer"
value=
"0"
/>
<AuxValue
name=
"FormSettings_autoSetComponentName"
type=
"java.lang.Boolean"
value=
"false"
/>
<AuxValue
name=
"FormSettings_generateFQN"
type=
"java.lang.Boolean"
value=
"true"
/>
<AuxValue
name=
"FormSettings_generateMnemonicsCode"
type=
"java.lang.Boolean"
value=
"false"
/>
<AuxValue
name=
"FormSettings_i18nAutoMode"
type=
"java.lang.Boolean"
value=
"false"
/>
<AuxValue
name=
"FormSettings_layoutCodeTarget"
type=
"java.lang.Integer"
value=
"1"
/>
<AuxValue
name=
"FormSettings_listenerGenerationStyle"
type=
"java.lang.Integer"
value=
"0"
/>
<AuxValue
name=
"FormSettings_variablesLocal"
type=
"java.lang.Boolean"
value=
"false"
/>
<AuxValue
name=
"FormSettings_variablesModifier"
type=
"java.lang.Integer"
value=
"2"
/>
</AuxValues>
<Layout>
<DimensionLayout
dim=
"0"
>
<Group
type=
"103"
groupAlignment=
"0"
attributes=
"0"
>
<Group
type=
"102"
attributes=
"0"
>
<Group
type=
"103"
groupAlignment=
"0"
attributes=
"0"
>
<Group
type=
"102"
attributes=
"0"
>
<EmptySpace
min=
"70"
pref=
"70"
max=
"-2"
attributes=
"0"
/>
<Group
type=
"103"
groupAlignment=
"0"
attributes=
"0"
>
<Component
id=
"loginLabel"
min=
"-2"
max=
"-2"
attributes=
"0"
/>
<Component
id=
"registerLabel"
min=
"-2"
max=
"-2"
attributes=
"0"
/>
</Group>
</Group>
<Group
type=
"102"
attributes=
"0"
>
<EmptySpace
min=
"90"
pref=
"90"
max=
"-2"
attributes=
"0"
/>
<Component
id=
"usernameLabel"
min=
"-2"
pref=
"70"
max=
"-2"
attributes=
"0"
/>
<EmptySpace
min=
"37"
pref=
"37"
max=
"-2"
attributes=
"0"
/>
<Component
id=
"usernameTextField"
min=
"-2"
pref=
"128"
max=
"-2"
attributes=
"0"
/>
</Group>
<Group
type=
"102"
attributes=
"0"
>
<EmptySpace
min=
"90"
pref=
"90"
max=
"-2"
attributes=
"0"
/>
<Component
id=
"passwordLabel"
min=
"-2"
pref=
"70"
max=
"-2"
attributes=
"0"
/>
<EmptySpace
min=
"37"
pref=
"37"
max=
"-2"
attributes=
"0"
/>
<Component
id=
"passwordTextField"
min=
"-2"
pref=
"128"
max=
"-2"
attributes=
"0"
/>
</Group>
<Group
type=
"102"
attributes=
"0"
>
<EmptySpace
min=
"150"
pref=
"150"
max=
"-2"
attributes=
"0"
/>
<Group
type=
"103"
groupAlignment=
"0"
attributes=
"0"
>
<Component
id=
"registerButton"
min=
"-2"
pref=
"77"
max=
"-2"
attributes=
"0"
/>
<Group
type=
"102"
attributes=
"0"
>
<EmptySpace
min=
"70"
pref=
"70"
max=
"-2"
attributes=
"0"
/>
<Component
id=
"registernowLabel"
min=
"-2"
max=
"-2"
attributes=
"0"
/>
</Group>
<Group
type=
"102"
attributes=
"0"
>
<EmptySpace
min=
"80"
pref=
"80"
max=
"-2"
attributes=
"0"
/>
<Component
id=
"loginButton"
min=
"-2"
max=
"-2"
attributes=
"0"
/>
</Group>
</Group>
</Group>
</Group>
<EmptySpace
min=
"0"
pref=
"0"
max=
"32767"
attributes=
"0"
/>
</Group>
<Group
type=
"102"
attributes=
"0"
>
<EmptySpace
max=
"-2"
attributes=
"0"
/>
<Group
type=
"103"
groupAlignment=
"0"
attributes=
"0"
>
<Group
type=
"102"
alignment=
"0"
attributes=
"0"
>
<Component
id=
"messageLabel"
min=
"-2"
pref=
"382"
max=
"-2"
attributes=
"0"
/>
<EmptySpace
pref=
"67"
max=
"32767"
attributes=
"0"
/>
</Group>
<Group
type=
"102"
alignment=
"0"
attributes=
"0"
>
<Component
id=
"serverLabel"
min=
"-2"
max=
"-2"
attributes=
"0"
/>
<EmptySpace
type=
"unrelated"
max=
"-2"
attributes=
"0"
/>
<Component
id=
"serverTextField"
min=
"-2"
pref=
"135"
max=
"-2"
attributes=
"0"
/>
<EmptySpace
max=
"32767"
attributes=
"0"
/>
<Component
id=
"backLabel"
min=
"-2"
max=
"-2"
attributes=
"0"
/>
<EmptySpace
min=
"-2"
pref=
"45"
max=
"-2"
attributes=
"0"
/>
</Group>
</Group>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout
dim=
"1"
>
<Group
type=
"103"
groupAlignment=
"0"
attributes=
"0"
>
<Group
type=
"102"
attributes=
"0"
>
<EmptySpace
max=
"-2"
attributes=
"0"
/>
<Group
type=
"103"
groupAlignment=
"3"
attributes=
"0"
>
<Component
id=
"serverLabel"
alignment=
"3"
min=
"-2"
max=
"-2"
attributes=
"0"
/>
<Component
id=
"serverTextField"
alignment=
"3"
min=
"-2"
max=
"-2"
attributes=
"0"
/>
<Component
id=
"backLabel"
alignment=
"3"
min=
"-2"
max=
"-2"
attributes=
"0"
/>
</Group>
<EmptySpace
max=
"-2"
attributes=
"0"
/>
<Component
id=
"messageLabel"
min=
"-2"
pref=
"20"
max=
"-2"
attributes=
"0"
/>
<EmptySpace
type=
"unrelated"
max=
"-2"
attributes=
"0"
/>
<Group
type=
"103"
groupAlignment=
"0"
attributes=
"0"
>
<Component
id=
"loginLabel"
min=
"-2"
max=
"-2"
attributes=
"0"
/>
<Component
id=
"registerLabel"
min=
"-2"
max=
"-2"
attributes=
"0"
/>
</Group>
<EmptySpace
min=
"17"
pref=
"17"
max=
"-2"
attributes=
"0"
/>
<Group
type=
"103"
groupAlignment=
"0"
attributes=
"0"
>
<Group
type=
"102"
attributes=
"0"
>
<EmptySpace
min=
"6"
pref=
"6"
max=
"-2"
attributes=
"0"
/>
<Component
id=
"usernameLabel"
min=
"-2"
max=
"-2"
attributes=
"0"
/>
</Group>
<Component
id=
"usernameTextField"
min=
"-2"
max=
"-2"
attributes=
"0"
/>
</Group>
<EmptySpace
min=
"18"
pref=
"18"
max=
"-2"
attributes=
"0"
/>
<Group
type=
"103"
groupAlignment=
"0"
attributes=
"0"
>
<Group
type=
"102"
attributes=
"0"
>
<EmptySpace
min=
"8"
pref=
"8"
max=
"-2"
attributes=
"0"
/>
<Component
id=
"passwordLabel"
min=
"-2"
max=
"-2"
attributes=
"0"
/>
</Group>
<Component
id=
"passwordTextField"
min=
"-2"
max=
"-2"
attributes=
"0"
/>
</Group>
<EmptySpace
min=
"16"
pref=
"16"
max=
"-2"
attributes=
"0"
/>
<Group
type=
"103"
groupAlignment=
"0"
attributes=
"0"
>
<Component
id=
"registerButton"
min=
"-2"
max=
"-2"
attributes=
"0"
/>
<Component
id=
"registernowLabel"
min=
"-2"
max=
"-2"
attributes=
"0"
/>
<Group
type=
"102"
attributes=
"0"
>
<EmptySpace
min=
"20"
pref=
"20"
max=
"-2"
attributes=
"0"
/>
<Component
id=
"loginButton"
min=
"-2"
max=
"-2"
attributes=
"0"
/>
</Group>
</Group>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component
class=
"javax.swing.JLabel"
name=
"loginLabel"
>
<Properties>
<Property
name=
"font"
type=
"java.awt.Font"
editor=
"org.netbeans.beaninfo.editors.FontEditor"
>
<Font
name=
"Tahoma"
size=
"14"
style=
"0"
/>
</Property>
<Property
name=
"text"
type=
"java.lang.String"
value=
"LOGIN"
/>
</Properties>
</Component>
<Component
class=
"javax.swing.JLabel"
name=
"registerLabel"
>
<Properties>
<Property
name=
"font"
type=
"java.awt.Font"
editor=
"org.netbeans.beaninfo.editors.FontEditor"
>
<Font
name=
"Tahoma"
size=
"14"
style=
"0"
/>
</Property>
<Property
name=
"text"
type=
"java.lang.String"
value=
"REGISTER"
/>
</Properties>
</Component>
<Component
class=
"javax.swing.JLabel"
name=
"usernameLabel"
>
<Properties>
<Property
name=
"text"
type=
"java.lang.String"
value=
"Username"
/>
</Properties>
</Component>
<Component
class=
"javax.swing.JLabel"
name=
"passwordLabel"
>
<Properties>
<Property
name=
"text"
type=
"java.lang.String"
value=
"Password"
/>
</Properties>
</Component>
<Component
class=
"javax.swing.JTextField"
name=
"usernameTextField"
>
</Component>
<Component
class=
"javax.swing.JTextField"
name=
"passwordTextField"
>
</Component>
<Component
class=
"javax.swing.JLabel"
name=
"registernowLabel"
>
<Properties>
<Property
name=
"text"
type=
"java.lang.String"
value=
"Register Now!"
/>
</Properties>
<Events>
<EventHandler
event=
"mouseClicked"
listener=
"java.awt.event.MouseListener"
parameters=
"java.awt.event.MouseEvent"
handler=
"registernowLabelMouseClicked"
/>
</Events>
</Component>
<Component
class=
"javax.swing.JButton"
name=
"loginButton"
>
<Properties>
<Property
name=
"text"
type=
"java.lang.String"
value=
"Login"
/>
</Properties>
<Events>
<EventHandler
event=
"actionPerformed"
listener=
"java.awt.event.ActionListener"
parameters=
"java.awt.event.ActionEvent"
handler=
"loginButtonActionPerformed"
/>
</Events>
</Component>
<Component
class=
"javax.swing.JButton"
name=
"registerButton"
>
<Properties>
<Property
name=
"text"
type=
"java.lang.String"
value=
"Register"
/>
</Properties>
<Events>
<EventHandler
event=
"actionPerformed"
listener=
"java.awt.event.ActionListener"
parameters=
"java.awt.event.ActionEvent"
handler=
"registerButtonActionPerformed"
/>
</Events>
</Component>
<Component
class=
"javax.swing.JLabel"
name=
"messageLabel"
>
</Component>
<Component
class=
"javax.swing.JTextField"
name=
"serverTextField"
>
<Properties>
<Property
name=
"text"
type=
"java.lang.String"
value=
"localhost"
/>
</Properties>
</Component>
<Component
class=
"javax.swing.JLabel"
name=
"serverLabel"
>
<Properties>
<Property
name=
"text"
type=
"java.lang.String"
value=
"Server:"
/>
</Properties>
</Component>
<Component
class=
"javax.swing.JLabel"
name=
"backLabel"
>
<Properties>
<Property
name=
"text"
type=
"java.lang.String"
value=
"Back"
/>
</Properties>
<Events>
<EventHandler
event=
"mouseClicked"
listener=
"java.awt.event.MouseListener"
parameters=
"java.awt.event.MouseEvent"
handler=
"backLabelMouseClicked"
/>
</Events>
</Component>
</SubComponents>
</Form>
src/client/src/tcpclient/LoginPage.java
deleted
100644 → 0
View file @
fbfd7708
package
tcpclient
;
import
java.io.IOException
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
org.json.JSONObject
;
public
class
LoginPage
extends
javax
.
swing
.
JFrame
{
//atribut
private
TCPClient
client
;
private
boolean
connected
;
//server telah connect
public
LoginPage
()
{
initComponents
();
registerLabel
.
setVisible
(
false
);
registerButton
.
setVisible
(
false
);
backLabel
.
setVisible
(
false
);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings
(
"unchecked"
)
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private
void
initComponents
()
{
loginLabel
=
new
javax
.
swing
.
JLabel
();
registerLabel
=
new
javax
.
swing
.
JLabel
();
usernameLabel
=
new
javax
.
swing
.
JLabel
();
passwordLabel
=
new
javax
.
swing
.
JLabel
();
usernameTextField
=
new
javax
.
swing
.
JTextField
();
passwordTextField
=
new
javax
.
swing
.
JTextField
();
registernowLabel
=
new
javax
.
swing
.
JLabel
();
loginButton
=
new
javax
.
swing
.
JButton
();
registerButton
=
new
javax
.
swing
.
JButton
();
messageLabel
=
new
javax
.
swing
.
JLabel
();
serverTextField
=
new
javax
.
swing
.
JTextField
();
serverLabel
=
new
javax
.
swing
.
JLabel
();
backLabel
=
new
javax
.
swing
.
JLabel
();
setDefaultCloseOperation
(
javax
.
swing
.
WindowConstants
.
EXIT_ON_CLOSE
);
setTitle
(
"Login/Register"
);
setBackground
(
new
java
.
awt
.
Color
(
153
,
204
,
255
));
setCursor
(
new
java
.
awt
.
Cursor
(
java
.
awt
.
Cursor
.
DEFAULT_CURSOR
));
setFont
(
new
java
.
awt
.
Font
(
"FISHfingers"
,
0
,
10
));
// NOI18N
setForeground
(
new
java
.
awt
.
Color
(
153
,
153
,
255
));
setLocationByPlatform
(
true
);
setMinimumSize
(
new
java
.
awt
.
Dimension
(
400
,
300
));
setName
(
"loginFrame"
);
// NOI18N
setResizable
(
false
);
loginLabel
.
setFont
(
new
java
.
awt
.
Font
(
"Tahoma"
,
0
,
14
));
// NOI18N
loginLabel
.
setText
(
"LOGIN"
);
registerLabel
.
setFont
(
new
java
.
awt
.
Font
(
"Tahoma"
,
0
,
14
));
// NOI18N
registerLabel
.
setText
(
"REGISTER"
);
usernameLabel
.
setText
(
"Username"
);
passwordLabel
.
setText
(
"Password"
);
registernowLabel
.
setText
(
"Register Now!"
);
registernowLabel
.
addMouseListener
(
new
java
.
awt
.
event
.
MouseAdapter
()
{
public
void
mouseClicked
(
java
.
awt
.
event
.
MouseEvent
evt
)
{
registernowLabelMouseClicked
(
evt
);
}
});
loginButton
.
setText
(
"Login"
);
loginButton
.
addActionListener
(
new
java
.
awt
.
event
.
ActionListener
()
{
public
void
actionPerformed
(
java
.
awt
.
event
.
ActionEvent
evt
)
{
loginButtonActionPerformed
(
evt
);
}
});
registerButton
.
setText
(
"Register"
);
registerButton
.
addActionListener
(
new
java
.
awt
.
event
.
ActionListener
()
{
public
void
actionPerformed
(
java
.
awt
.
event
.
ActionEvent
evt
)
{
registerButtonActionPerformed
(
evt
);
}
});
serverTextField
.
setText
(
"localhost"
);
serverLabel
.
setText
(
"Server:"
);
backLabel
.
setText
(
"Back"
);
backLabel
.
addMouseListener
(
new
java
.
awt
.
event
.
MouseAdapter
()
{
public
void
mouseClicked
(
java
.
awt
.
event
.
MouseEvent
evt
)
{
backLabelMouseClicked
(
evt
);
}
});
javax
.
swing
.
GroupLayout
layout
=
new
javax
.
swing
.
GroupLayout
(
getContentPane
());
getContentPane
().
setLayout
(
layout
);
layout
.
setHorizontalGroup
(
layout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
LEADING
)
.
addGroup
(
layout
.
createSequentialGroup
()
.
addGroup
(
layout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
LEADING
)
.
addGroup
(
layout
.
createSequentialGroup
()
.
addGap
(
70
,
70
,
70
)
.
addGroup
(
layout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
LEADING
)
.
addComponent
(
loginLabel
)
.
addComponent
(
registerLabel
)))
.
addGroup
(
layout
.
createSequentialGroup
()
.
addGap
(
90
,
90
,
90
)
.
addComponent
(
usernameLabel
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
70
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
)
.
addGap
(
37
,
37
,
37
)
.
addComponent
(
usernameTextField
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
128
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
))
.
addGroup
(
layout
.
createSequentialGroup
()
.
addGap
(
90
,
90
,
90
)
.
addComponent
(
passwordLabel
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
70
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
)
.
addGap
(
37
,
37
,
37
)
.
addComponent
(
passwordTextField
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
128
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
))
.
addGroup
(
layout
.
createSequentialGroup
()
.
addGap
(
150
,
150
,
150
)
.
addGroup
(
layout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
LEADING
)
.
addComponent
(
registerButton
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
77
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
)
.
addGroup
(
layout
.
createSequentialGroup
()
.
addGap
(
70
,
70
,
70
)
.
addComponent
(
registernowLabel
))
.
addGroup
(
layout
.
createSequentialGroup
()
.
addGap
(
80
,
80
,
80
)
.
addComponent
(
loginButton
)))))
.
addGap
(
0
,
0
,
Short
.
MAX_VALUE
))
.
addGroup
(
layout
.
createSequentialGroup
()
.
addContainerGap
()
.
addGroup
(
layout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
LEADING
)
.
addGroup
(
layout
.
createSequentialGroup
()
.
addComponent
(
messageLabel
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
382
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
)
.
addContainerGap
(
67
,
Short
.
MAX_VALUE
))
.
addGroup
(
layout
.
createSequentialGroup
()
.
addComponent
(
serverLabel
)
.
addPreferredGap
(
javax
.
swing
.
LayoutStyle
.
ComponentPlacement
.
UNRELATED
)
.
addComponent
(
serverTextField
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
135
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
)
.
addPreferredGap
(
javax
.
swing
.
LayoutStyle
.
ComponentPlacement
.
RELATED
,
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
Short
.
MAX_VALUE
)
.
addComponent
(
backLabel
)
.
addGap
(
45
,
45
,
45
))))
);
layout
.
setVerticalGroup
(
layout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
LEADING
)
.
addGroup
(
layout
.
createSequentialGroup
()
.
addContainerGap
()
.
addGroup
(
layout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
BASELINE
)
.
addComponent
(
serverLabel
)
.
addComponent
(
serverTextField
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
)
.
addComponent
(
backLabel
))
.
addPreferredGap
(
javax
.
swing
.
LayoutStyle
.
ComponentPlacement
.
RELATED
)
.
addComponent
(
messageLabel
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
20
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
)
.
addPreferredGap
(
javax
.
swing
.
LayoutStyle
.
ComponentPlacement
.
UNRELATED
)
.
addGroup
(
layout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
LEADING
)
.
addComponent
(
loginLabel
)
.
addComponent
(
registerLabel
))
.
addGap
(
17
,
17
,
17
)
.
addGroup
(
layout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
LEADING
)
.
addGroup
(
layout
.
createSequentialGroup
()
.
addGap
(
6
,
6
,
6
)
.
addComponent
(
usernameLabel
))
.
addComponent
(
usernameTextField
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
))
.
addGap
(
18
,
18
,
18
)
.
addGroup
(
layout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
LEADING
)
.
addGroup
(
layout
.
createSequentialGroup
()
.
addGap
(
8
,
8
,
8
)
.
addComponent
(
passwordLabel
))
.
addComponent
(
passwordTextField
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
))
.
addGap
(
16
,
16
,
16
)
.
addGroup
(
layout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
LEADING
)
.
addComponent
(
registerButton
)
.
addComponent
(
registernowLabel
)
.
addGroup
(
layout
.
createSequentialGroup
()
.
addGap
(
20
,
20
,
20
)
.
addComponent
(
loginButton
))))
);
pack
();
}
// </editor-fold>//GEN-END:initComponents
//make connection to server if not connected
private
void
makeConnection
()
{
if
(!
connected
)
{
String
ipAddress
=
serverTextField
.
getText
();
if
(
ipAddress
.
isEmpty
())
{
setMessage
(
"server must be filled"
);
}
else
{
serverTextField
.
setEnabled
(
false
);
int
port
=
6789
;
try
{
client
=
new
TCPClient
(
ipAddress
,
port
);
connected
=
true
;
setMessage
(
"success connected to server"
);
}
catch
(
IOException
ex
)
{
setMessage
(
"failed connected to server"
);
Logger
.
getLogger
(
LoginPage
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
}
}
}
private
void
loginButtonActionPerformed
(
java
.
awt
.
event
.
ActionEvent
evt
)
{
//GEN-FIRST:event_loginButtonActionPerformed
makeConnection
();
if
(
connected
)
{
String
username
=
usernameTextField
.
getText
();
String
password
=
passwordTextField
.
getText
();
JSONObject
response
;
try
{
response
=
client
.
login
(
username
,
password
);
if
(
response
.
getString
(
"status"
).
equals
(
"ok"
))
{
client
.
token
=
response
.
getString
(
"token"
);
client
.
x
=
response
.
getInt
(
"x"
);
client
.
y
=
response
.
getInt
(
"y"
);
setMessage
(
"Login success"
);
}
else
{
setMessage
(
response
.
getString
(
"description"
));
}
}
catch
(
Exception
ex
)
{
setMessage
(
"server not respond"
);
Logger
.
getLogger
(
LoginPage
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
}
}
//GEN-LAST:event_loginButtonActionPerformed
private
void
registerButtonActionPerformed
(
java
.
awt
.
event
.
ActionEvent
evt
)
{
//GEN-FIRST:event_registerButtonActionPerformed
makeConnection
();
if
(
connected
)
{
String
username
=
usernameTextField
.
getText
();
String
password
=
passwordTextField
.
getText
();
try
{
JSONObject
response
=
client
.
register
(
username
,
password
);
if
(
response
.
get
(
"status"
).
equals
(
"ok"
))
{
setMessage
(
"register success"
);
}
else
{
setMessage
(
response
.
getString
(
"description"
));
}
}
catch
(
Exception
ex
)
{
setMessage
(
ex
.
getMessage
());
Logger
.
getLogger
(
LoginPage
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
}
}
//GEN-LAST:event_registerButtonActionPerformed
private
void
registernowLabelMouseClicked
(
java
.
awt
.
event
.
MouseEvent
evt
)
{
//GEN-FIRST:event_registernowLabelMouseClicked
registernowLabel
.
setVisible
(
false
);
loginButton
.
setVisible
(
false
);
loginLabel
.
setVisible
(
false
);
registerLabel
.
setVisible
(
true
);
registerButton
.
setVisible
(
true
);
backLabel
.
setVisible
(
true
);
messageLabel
.
setText
(
""
);
}
//GEN-LAST:event_registernowLabelMouseClicked
private
void
backLabelMouseClicked
(
java
.
awt
.
event
.
MouseEvent
evt
)
{
//GEN-FIRST:event_backLabelMouseClicked
registernowLabel
.
setVisible
(
true
);
loginButton
.
setVisible
(
true
);
loginLabel
.
setVisible
(
true
);
registerLabel
.
setVisible
(
false
);
registerButton
.
setVisible
(
false
);
backLabel
.
setVisible
(
false
);
messageLabel
.
setText
(
""
);
}
//GEN-LAST:event_backLabelMouseClicked
/**
* @param args the command line arguments
*/
// public static void main(String args[]) {
// /* Set the Nimbus look and feel */
// //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
// /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
// * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
// */
// try {
// for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
// if ("Nimbus".equals(info.getName())) {
// javax.swing.UIManager.setLookAndFeel(info.getClassName());
// break;
// }
// }
// } catch (ClassNotFoundException ex) {
// java.util.logging.Logger.getLogger(LoginPage.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
// } catch (InstantiationException ex) {
// java.util.logging.Logger.getLogger(LoginPage.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
// } catch (IllegalAccessException ex) {
// java.util.logging.Logger.getLogger(LoginPage.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
// } catch (javax.swing.UnsupportedLookAndFeelException ex) {
// java.util.logging.Logger.getLogger(LoginPage.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
// }
// //</editor-fold>
//
// /* Create and display the form */