Commit 5f611b01 authored by Muhammad Yafi's avatar Muhammad Yafi
Browse files

fixing client

parent faab9d79
......@@ -6,6 +6,7 @@ import java.awt.image.BufferedImage;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
......@@ -119,11 +120,14 @@ public class Helper {
try
{
client = new Socket(InetAddress.getByName(server_address), Integer.parseInt(port));
DataInputStream in = new DataInputStream(client.getInputStream());
DataOutputStream output = new DataOutputStream(client.getOutputStream());
output.write(message.getBytes());
String response = in.readUTF();
InputStream stream = client.getInputStream();
byte[] data = new byte[4096];
int count = stream.read(data);
String response = new String(data);
response = response.substring(0, count);
client.close();
return response;
}
......
......@@ -39,9 +39,6 @@
<SubComponents>
<Component class="javax.swing.JLabel" name="server_address_label">
<Properties>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="0" green="0" red="0" type="rgb"/>
</Property>
<Property name="text" type="java.lang.String" value="Server Address"/>
</Properties>
<Constraints>
......@@ -52,9 +49,6 @@
</Component>
<Component class="javax.swing.JLabel" name="username_label">
<Properties>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="0" green="0" red="0" type="rgb"/>
</Property>
<Property name="text" type="java.lang.String" value="Username"/>
</Properties>
<Constraints>
......@@ -65,9 +59,6 @@
</Component>
<Component class="javax.swing.JLabel" name="password_label">
<Properties>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="0" green="0" red="0" type="rgb"/>
</Property>
<Property name="text" type="java.lang.String" value="Password"/>
</Properties>
<Constraints>
......@@ -78,7 +69,7 @@
</Component>
<Component class="javax.swing.JTextField" name="server_address_textfield">
<Properties>
<Property name="text" type="java.lang.String" value="localhost"/>
<Property name="text" type="java.lang.String" value="167.205.35.100"/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[4, 25]"/>
</Property>
......@@ -91,7 +82,7 @@
</Component>
<Component class="javax.swing.JTextField" name="username_textfield">
<Properties>
<Property name="text" type="java.lang.String" value="Akatsuki"/>
<Property name="text" type="java.lang.String" value="dummy"/>
<Property name="toolTipText" type="java.lang.String" value=""/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[4, 25]"/>
......@@ -144,9 +135,6 @@
</Component>
<Component class="javax.swing.JLabel" name="port_label">
<Properties>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="0" green="0" red="0" type="rgb"/>
</Property>
<Property name="text" type="java.lang.String" value="Port"/>
</Properties>
<Constraints>
......@@ -157,8 +145,11 @@
</Component>
<Component class="javax.swing.JTextField" name="port_textfield">
<Properties>
<Property name="text" type="java.lang.String" value="8080"/>
<Property name="text" type="java.lang.String" value="8000"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="port_textfieldActionPerformed"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
<AbsoluteConstraints x="470" y="330" width="140" height="30"/>
......@@ -167,11 +158,14 @@
</Component>
<Component class="javax.swing.JPasswordField" name="password_textfield">
<Properties>
<Property name="text" type="java.lang.String" value="LogHorizon"/>
<Property name="text" type="java.lang.String" value="dummy"/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[109, 25]"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="password_textfieldActionPerformed"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
<AbsoluteConstraints x="290" y="290" width="320" height="30"/>
......
......@@ -51,27 +51,24 @@ public class LoginScreen extends javax.swing.JFrame {
setResizable(false);
getContentPane().setLayout(null);
server_address_label.setForeground(new java.awt.Color(0, 0, 0));
server_address_label.setText("Server Address");
getContentPane().add(server_address_label);
server_address_label.setBounds(180, 330, 100, 16);
server_address_label.setBounds(180, 330, 100, 14);
username_label.setForeground(new java.awt.Color(0, 0, 0));
username_label.setText("Username");
getContentPane().add(username_label);
username_label.setBounds(180, 250, 80, 20);
password_label.setForeground(new java.awt.Color(0, 0, 0));
password_label.setText("Password");
getContentPane().add(password_label);
password_label.setBounds(180, 290, 80, 16);
password_label.setBounds(180, 290, 80, 14);
server_address_textfield.setText("localhost");
server_address_textfield.setText("167.205.35.100");
server_address_textfield.setPreferredSize(new java.awt.Dimension(4, 25));
getContentPane().add(server_address_textfield);
server_address_textfield.setBounds(290, 330, 140, 30);
username_textfield.setText("Akatsuki");
username_textfield.setText("dummy");
username_textfield.setToolTipText("");
username_textfield.setPreferredSize(new java.awt.Dimension(4, 25));
getContentPane().add(username_textfield);
......@@ -84,7 +81,7 @@ public class LoginScreen extends javax.swing.JFrame {
}
});
getContentPane().add(exit_button);
exit_button.setBounds(540, 370, 70, 26);
exit_button.setBounds(540, 370, 70, 23);
login_button.setText("Login");
login_button.addActionListener(new java.awt.event.ActionListener() {
......@@ -93,7 +90,7 @@ public class LoginScreen extends javax.swing.JFrame {
}
});
getContentPane().add(login_button);
login_button.setBounds(290, 370, 80, 26);
login_button.setBounds(290, 370, 80, 23);
register_button.setText("Register");
register_button.addActionListener(new java.awt.event.ActionListener() {
......@@ -102,19 +99,28 @@ public class LoginScreen extends javax.swing.JFrame {
}
});
getContentPane().add(register_button);
register_button.setBounds(410, 370, 90, 26);
register_button.setBounds(410, 370, 90, 23);
port_label.setForeground(new java.awt.Color(0, 0, 0));
port_label.setText("Port");
getContentPane().add(port_label);
port_label.setBounds(440, 330, 30, 16);
port_label.setBounds(440, 330, 30, 14);
port_textfield.setText("8080");
port_textfield.setText("8000");
port_textfield.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
port_textfieldActionPerformed(evt);
}
});
getContentPane().add(port_textfield);
port_textfield.setBounds(470, 330, 140, 30);
password_textfield.setText("LogHorizon");
password_textfield.setText("dummy");
password_textfield.setPreferredSize(new java.awt.Dimension(109, 25));
password_textfield.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
password_textfieldActionPerformed(evt);
}
});
getContentPane().add(password_textfield);
password_textfield.setBounds(290, 290, 320, 30);
......@@ -169,6 +175,14 @@ public class LoginScreen extends javax.swing.JFrame {
}
}//GEN-LAST:event_register_buttonActionPerformed
private void port_textfieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_port_textfieldActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_port_textfieldActionPerformed
private void password_textfieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_password_textfieldActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_password_textfieldActionPerformed
private Boolean validasi_input()
{
if (username_textfield.getText().length() == 0 ||
......
......@@ -91,27 +91,27 @@ public class MainScreen extends javax.swing.JFrame {
x_label.setText("x");
getContentPane().add(x_label);
x_label.setBounds(520, 230, 10, 16);
x_label.setBounds(520, 230, 10, 14);
y_label.setText("y");
getContentPane().add(y_label);
y_label.setBounds(520, 260, 10, 16);
y_label.setBounds(520, 260, 10, 14);
position_label.setText("Position");
getContentPane().add(position_label);
position_label.setBounds(520, 140, 60, 16);
position_label.setBounds(520, 140, 60, 14);
current_time_label.setText("Current Time");
getContentPane().add(current_time_label);
current_time_label.setBounds(520, 200, 80, 16);
current_time_label.setBounds(520, 200, 80, 14);
map_label.setText("Map");
getContentPane().add(map_label);
map_label.setBounds(520, 110, 41, 16);
map_label.setBounds(520, 110, 41, 14);
time_label.setText("Time");
getContentPane().add(time_label);
time_label.setBounds(520, 170, 41, 16);
time_label.setBounds(520, 170, 41, 14);
getContentPane().add(position_detail_label);
position_detail_label.setBounds(600, 140, 130, 16);
getContentPane().add(current_time_detail_label);
......@@ -145,7 +145,7 @@ public class MainScreen extends javax.swing.JFrame {
}
});
getContentPane().add(field_button);
field_button.setBounds(570, 300, 100, 26);
field_button.setBounds(570, 300, 100, 23);
inventory_button.setText("Inventory");
inventory_button.addActionListener(new java.awt.event.ActionListener() {
......@@ -154,7 +154,7 @@ public class MainScreen extends javax.swing.JFrame {
}
});
getContentPane().add(inventory_button);
inventory_button.setBounds(570, 340, 100, 26);
inventory_button.setBounds(570, 340, 100, 23);
mix_item_button.setText("Mix Item");
mix_item_button.addActionListener(new java.awt.event.ActionListener() {
......@@ -163,7 +163,7 @@ public class MainScreen extends javax.swing.JFrame {
}
});
getContentPane().add(mix_item_button);
mix_item_button.setBounds(570, 370, 100, 26);
mix_item_button.setBounds(570, 370, 100, 23);
offer_button.setText("Offer");
offer_button.addActionListener(new java.awt.event.ActionListener() {
......@@ -172,7 +172,7 @@ public class MainScreen extends javax.swing.JFrame {
}
});
getContentPane().add(offer_button);
offer_button.setBounds(570, 440, 100, 26);
offer_button.setBounds(570, 440, 100, 23);
logout_button.setText("Logout");
logout_button.addActionListener(new java.awt.event.ActionListener() {
......@@ -181,7 +181,7 @@ public class MainScreen extends javax.swing.JFrame {
}
});
getContentPane().add(logout_button);
logout_button.setBounds(630, 530, 100, 26);
logout_button.setBounds(630, 530, 100, 23);
tradebox_button.setText("Tradebox");
tradebox_button.addActionListener(new java.awt.event.ActionListener() {
......@@ -190,7 +190,7 @@ public class MainScreen extends javax.swing.JFrame {
}
});
getContentPane().add(tradebox_button);
tradebox_button.setBounds(570, 410, 100, 26);
tradebox_button.setBounds(570, 410, 100, 23);
find_item_button.setText("Find Item");
find_item_button.addActionListener(new java.awt.event.ActionListener() {
......@@ -199,7 +199,7 @@ public class MainScreen extends javax.swing.JFrame {
}
});
getContentPane().add(find_item_button);
find_item_button.setBounds(570, 470, 100, 26);
find_item_button.setBounds(570, 470, 100, 23);
background_label.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/mainscreen_background.jpg"))); // NOI18N
getContentPane().add(background_label);
......
......@@ -64,6 +64,7 @@ class ConnectionHandler:
try:
# handle ping purpose
if (str_url == ''):
print('just ping request')
return
data = json.loads(str_url)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment