Commit acc8545b authored by Timothy Pratama's avatar Timothy Pratama
Browse files

(client) fix find item GUI.

parent ae2fa120
...@@ -164,7 +164,7 @@ ...@@ -164,7 +164,7 @@
</Properties> </Properties>
<Constraints> <Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
<AbsoluteConstraints x="220" y="430" width="-1" height="-1"/> <AbsoluteConstraints x="270" y="420" width="-1" height="-1"/>
</Constraint> </Constraint>
</Constraints> </Constraints>
</Component> </Component>
...@@ -192,7 +192,7 @@ ...@@ -192,7 +192,7 @@
</Events> </Events>
<Constraints> <Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
<AbsoluteConstraints x="260" y="430" width="170" height="-1"/> <AbsoluteConstraints x="310" y="420" width="170" height="-1"/>
</Constraint> </Constraint>
</Constraints> </Constraints>
</Component> </Component>
...@@ -205,7 +205,7 @@ ...@@ -205,7 +205,7 @@
</Events> </Events>
<Constraints> <Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
<AbsoluteConstraints x="290" y="470" width="-1" height="-1"/> <AbsoluteConstraints x="340" y="460" width="-1" height="-1"/>
</Constraint> </Constraint>
</Constraints> </Constraints>
</Component> </Component>
......
...@@ -115,7 +115,7 @@ public class FindItemScreen extends javax.swing.JFrame { ...@@ -115,7 +115,7 @@ public class FindItemScreen extends javax.swing.JFrame {
item_label.setText("Item"); item_label.setText("Item");
getContentPane().add(item_label); getContentPane().add(item_label);
item_label.setBounds(220, 430, 25, 16); item_label.setBounds(270, 420, 25, 16);
jComboBox1.setMaximumRowCount(5); jComboBox1.setMaximumRowCount(5);
jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "--- Select an Item ---", "Honey", "Herbs", "Clay", "Mineral", "Potion", "Incense", "Gems", "Life Elixir", "Mana Crystal", "Philosopher Stone" })); jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "--- Select an Item ---", "Honey", "Herbs", "Clay", "Mineral", "Potion", "Incense", "Gems", "Life Elixir", "Mana Crystal", "Philosopher Stone" }));
...@@ -125,7 +125,7 @@ public class FindItemScreen extends javax.swing.JFrame { ...@@ -125,7 +125,7 @@ public class FindItemScreen extends javax.swing.JFrame {
} }
}); });
getContentPane().add(jComboBox1); getContentPane().add(jComboBox1);
jComboBox1.setBounds(260, 430, 170, 25); jComboBox1.setBounds(310, 420, 170, 25);
find_button.setText("Find"); find_button.setText("Find");
find_button.addActionListener(new java.awt.event.ActionListener() { find_button.addActionListener(new java.awt.event.ActionListener() {
...@@ -134,7 +134,7 @@ public class FindItemScreen extends javax.swing.JFrame { ...@@ -134,7 +134,7 @@ public class FindItemScreen extends javax.swing.JFrame {
} }
}); });
getContentPane().add(find_button); getContentPane().add(find_button);
find_button.setBounds(290, 470, 57, 26); find_button.setBounds(340, 460, 57, 26);
background_label.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/sendfine_background.png"))); // NOI18N background_label.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/sendfine_background.png"))); // NOI18N
getContentPane().add(background_label); getContentPane().add(background_label);
......
...@@ -123,24 +123,24 @@ public class Helper { ...@@ -123,24 +123,24 @@ public class Helper {
DataOutputStream output = new DataOutputStream(client.getOutputStream()); DataOutputStream output = new DataOutputStream(client.getOutputStream());
/* Python Server */ /* Python Server */
output.write(message.getBytes()); // output.write(message.getBytes());
/* Server Java */ /* Server Java */
// output.writeUTF(message); output.writeUTF(message);
InputStream stream = client.getInputStream(); InputStream stream = client.getInputStream();
/* Pthyon Server */ /* Pthyon Server */
byte[] data = new byte[4096]; // byte[] data = new byte[4096];
int count = stream.read(data); // int count = stream.read(data);
String response = new String(data); // String response = new String(data);
/* Server Java */ /* Server Java */
// DataInputStream input = new DataInputStream(stream); DataInputStream input = new DataInputStream(stream);
// String response = input.readUTF(); String response = input.readUTF();
/* Python Server */ /* Python Server */
response = response.substring(0, count); // response = response.substring(0, count);
/* Server Java */ /* Server Java */
......
...@@ -26,6 +26,10 @@ import org.json.simple.parser.ParseException; ...@@ -26,6 +26,10 @@ import org.json.simple.parser.ParseException;
*/ */
public class SearchResultScreen extends javax.swing.JFrame { public class SearchResultScreen extends javax.swing.JFrame {
private JLabel [] labels;
private ImageIcon [] icons;
private JButton[] buttons;
/** /**
* Creates new form FindResultScreen * Creates new form FindResultScreen
*/ */
...@@ -134,9 +138,9 @@ public class SearchResultScreen extends javax.swing.JFrame { ...@@ -134,9 +138,9 @@ public class SearchResultScreen extends javax.swing.JFrame {
try try
{ {
JSONArray offers = (JSONArray) parser.parse(Global.SuccessMessage); JSONArray offers = (JSONArray) parser.parse(Global.SuccessMessage);
JLabel [] labels = new JLabel[offers.size()*4]; labels = new JLabel[offers.size()*4];
ImageIcon [] icons = new ImageIcon[offers.size()*4]; icons = new ImageIcon[offers.size()*4];
JButton[] buttons = new JButton[offers.size()]; buttons = new JButton[offers.size()];
System.out.println("Offers: " + offers.toJSONString()); System.out.println("Offers: " + offers.toJSONString());
int j = 0; int j = 0;
int k = 0; int k = 0;
...@@ -188,9 +192,11 @@ public class SearchResultScreen extends javax.swing.JFrame { ...@@ -188,9 +192,11 @@ public class SearchResultScreen extends javax.swing.JFrame {
buttons[k] = new JButton(); buttons[k] = new JButton();
canvas_main_panel.add(buttons[k]); canvas_main_panel.add(buttons[k]);
buttons[k].setText("Buy"); buttons[k].setText("Buy");
int index1 = j;
int index2 = k;
buttons[k].addActionListener(new java.awt.event.ActionListener() { buttons[k].addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { public void actionPerformed(java.awt.event.ActionEvent evt) {
SendAccept(evt, temp.get(5).toString()); SendAccept(evt, temp.get(5).toString(), index1, index2);
} }
}); });
k++; k++;
...@@ -215,11 +221,17 @@ public class SearchResultScreen extends javax.swing.JFrame { ...@@ -215,11 +221,17 @@ public class SearchResultScreen extends javax.swing.JFrame {
dispose(); dispose();
}//GEN-LAST:event_back_buttonActionPerformed }//GEN-LAST:event_back_buttonActionPerformed
private void SendAccept(java.awt.event.ActionEvent evt, String other_token) { private void SendAccept(java.awt.event.ActionEvent evt, String other_token, int index1, int index2) {
boolean success = Helper.sendAccept(other_token); boolean success = Helper.sendAccept(other_token);
if(success) if(success)
{ {
JOptionPane.showMessageDialog(this, Global.SuccessMessage); JOptionPane.showMessageDialog(this, Global.SuccessMessage);
canvas_main_panel.remove(labels[index1-1]);
canvas_main_panel.remove(labels[index1-2]);
canvas_main_panel.remove(labels[index1-3]);
canvas_main_panel.remove(labels[index1-4]);
canvas_main_panel.remove(buttons[index2]);
repaint();
} }
else else
{ {
......
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