Commit 949adbb1 authored by Stephen's avatar Stephen
Browse files

Merged

parents 806fecd8 0519cfe5
......@@ -1687,7 +1687,7 @@
<Component id="FindIcon" min="-2" max="-2" attributes="0"/>
<Component id="Find" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="0" pref="165" max="32767" attributes="0"/>
<EmptySpace min="0" pref="174" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
......@@ -1732,14 +1732,14 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="FindPotion" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="FindHoney" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="FindHerbs" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="FindClay" alignment="0" min="-2" pref="155" max="-2" attributes="0"/>
<Component id="FindMineral" alignment="0" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="FindPotion" alignment="0" max="32767" attributes="0"/>
<Component id="FindHoney" alignment="0" max="32767" attributes="0"/>
<Component id="FindHerbs" alignment="0" max="32767" attributes="0"/>
<Component id="FindMineral" alignment="0" max="32767" attributes="0"/>
<Component id="FindClay" alignment="0" max="32767" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="36" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="FindIncense" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="FindGems" alignment="0" min="-2" max="-2" attributes="0"/>
......@@ -1758,7 +1758,6 @@
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/inventory/images/honey.PNG"/>
</Property>
<Property name="text" type="java.lang.String" value="jButton1"/>
<Property name="horizontalTextPosition" type="int" value="0"/>
<Property name="verticalTextPosition" type="int" value="3"/>
</Properties>
......@@ -1771,7 +1770,6 @@
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/inventory/images/herbs.PNG"/>
</Property>
<Property name="text" type="java.lang.String" value="jButton1"/>
<Property name="horizontalTextPosition" type="int" value="0"/>
<Property name="verticalTextPosition" type="int" value="3"/>
</Properties>
......@@ -1784,7 +1782,6 @@
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/inventory/images/clay.PNG"/>
</Property>
<Property name="text" type="java.lang.String" value="jButton1"/>
<Property name="horizontalTextPosition" type="int" value="0"/>
<Property name="verticalTextPosition" type="int" value="3"/>
</Properties>
......@@ -1797,7 +1794,6 @@
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/inventory/images/mineral.PNG"/>
</Property>
<Property name="text" type="java.lang.String" value="jButton1"/>
<Property name="horizontalTextPosition" type="int" value="0"/>
<Property name="verticalTextPosition" type="int" value="3"/>
</Properties>
......@@ -1810,7 +1806,6 @@
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/inventory/images/potion.PNG"/>
</Property>
<Property name="text" type="java.lang.String" value="jButton1"/>
<Property name="horizontalTextPosition" type="int" value="0"/>
<Property name="verticalTextPosition" type="int" value="3"/>
</Properties>
......@@ -1823,7 +1818,6 @@
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/inventory/images/stone.PNG"/>
</Property>
<Property name="text" type="java.lang.String" value="jButton1"/>
<Property name="horizontalTextPosition" type="int" value="0"/>
<Property name="verticalTextPosition" type="int" value="3"/>
</Properties>
......@@ -1836,7 +1830,6 @@
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/inventory/images/manaCrystal.PNG"/>
</Property>
<Property name="text" type="java.lang.String" value="jButton1"/>
<Property name="horizontalTextPosition" type="int" value="0"/>
<Property name="verticalTextPosition" type="int" value="3"/>
</Properties>
......@@ -1849,7 +1842,6 @@
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/inventory/images/lifeElixir.PNG"/>
</Property>
<Property name="text" type="java.lang.String" value="jButton1"/>
<Property name="horizontalTextPosition" type="int" value="0"/>
<Property name="verticalTextPosition" type="int" value="3"/>
</Properties>
......@@ -1862,7 +1854,6 @@
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/inventory/images/gems.PNG"/>
</Property>
<Property name="text" type="java.lang.String" value="jButton1"/>
<Property name="horizontalTextPosition" type="int" value="0"/>
<Property name="verticalTextPosition" type="int" value="3"/>
</Properties>
......@@ -1875,7 +1866,6 @@
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/inventory/images/incense.PNG"/>
</Property>
<Property name="text" type="java.lang.String" value="jButton1"/>
<Property name="horizontalTextPosition" type="int" value="0"/>
<Property name="verticalTextPosition" type="int" value="3"/>
</Properties>
......@@ -1907,7 +1897,7 @@
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="tradeitemPanel">
<Container class="javax.swing.JPanel" name="FindOfferItemPanel">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignCardLayout" value="org.netbeans.modules.form.compat2.layouts.DesignCardLayout$CardConstraintsDescription">
<CardConstraints cardName="TradeItemCard"/>
......@@ -1917,15 +1907,44 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="908" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="19" max="-2" attributes="0"/>
<Component id="FindOfferItemScrollPane" min="-2" pref="847" max="-2" attributes="0"/>
<EmptySpace pref="42" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="540" max="32767" attributes="0"/>
<Group type="102" alignment="1" attributes="0">
<EmptySpace pref="20" max="32767" attributes="0"/>
<Component id="FindOfferItemScrollPane" min="-2" pref="500" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="20" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JScrollPane" name="FindOfferItemScrollPane">
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTable" name="FindOfferItemTable">
<Properties>
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="tradeboxModel" type="code"/>
</Property>
<Property name="columnModel" type="javax.swing.table.TableColumnModel" editor="org.netbeans.modules.form.editors2.TableColumnModelEditor">
<TableColumnModel selectionModel="0"/>
</Property>
<Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor">
<TableHeader reorderingAllowed="true" resizingAllowed="true"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>
</SubComponents>
</Container>
......
......@@ -53,20 +53,22 @@ public class MainPage extends javax.swing.JFrame {
//atribut
private TCPClient client;
private TableModel mapModel;
private int MixItem1;
private int MixItem2;
private int OfferedItemId;
private int DemandedItemId;
private int FindId;
private int MixItem1 = -1;
private int MixItem2 = -1;
private int OfferedItemId = -1;
private int DemandedItemId = -1;
private int FindId = -1;
private Date currentTime;
private Date time;
private Timer timer;
private TradeboxTableModel tradeboxModel;
private TradeboxTableModel FindOfferBoxModel;
public MainPage() {
mapModel=new MapTableModel();
tradeboxModel=new TradeboxTableModel();
FindOfferBoxModel = new TradeboxTableModel();
initComponents();
//mapTable
MenuPanel.setVisible(false);
......@@ -197,7 +199,9 @@ public class MainPage extends javax.swing.JFrame {
FindIncense = new javax.swing.JButton();
FindIcon = new javax.swing.JButton();
Find = new javax.swing.JButton();
tradeitemPanel = new javax.swing.JPanel();
FindOfferItemPanel = new javax.swing.JPanel();
FindOfferItemScrollPane = new javax.swing.JScrollPane();
FindOfferItemTable = new javax.swing.JTable();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
......@@ -1312,7 +1316,6 @@ public class MainPage extends javax.swing.JFrame {
MainPanel.add(offerPanel, "OfferCard");
FindHoney.setIcon(new javax.swing.ImageIcon(getClass().getResource("/inventory/images/honey.PNG"))); // NOI18N
FindHoney.setText("jButton1");
FindHoney.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
FindHoney.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
FindHoney.addActionListener(new java.awt.event.ActionListener() {
......@@ -1322,7 +1325,6 @@ public class MainPage extends javax.swing.JFrame {
});
FindHerbs.setIcon(new javax.swing.ImageIcon(getClass().getResource("/inventory/images/herbs.PNG"))); // NOI18N
FindHerbs.setText("jButton1");
FindHerbs.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
FindHerbs.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
FindHerbs.addActionListener(new java.awt.event.ActionListener() {
......@@ -1332,7 +1334,6 @@ public class MainPage extends javax.swing.JFrame {
});
FindClay.setIcon(new javax.swing.ImageIcon(getClass().getResource("/inventory/images/clay.PNG"))); // NOI18N
FindClay.setText("jButton1");
FindClay.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
FindClay.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
FindClay.addActionListener(new java.awt.event.ActionListener() {
......@@ -1342,7 +1343,6 @@ public class MainPage extends javax.swing.JFrame {
});
FindMineral.setIcon(new javax.swing.ImageIcon(getClass().getResource("/inventory/images/mineral.PNG"))); // NOI18N
FindMineral.setText("jButton1");
FindMineral.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
FindMineral.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
FindMineral.addActionListener(new java.awt.event.ActionListener() {
......@@ -1352,7 +1352,6 @@ public class MainPage extends javax.swing.JFrame {
});
FindPotion.setIcon(new javax.swing.ImageIcon(getClass().getResource("/inventory/images/potion.PNG"))); // NOI18N
FindPotion.setText("jButton1");
FindPotion.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
FindPotion.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
FindPotion.addActionListener(new java.awt.event.ActionListener() {
......@@ -1362,7 +1361,6 @@ public class MainPage extends javax.swing.JFrame {
});
FindPhilosopherStone.setIcon(new javax.swing.ImageIcon(getClass().getResource("/inventory/images/stone.PNG"))); // NOI18N
FindPhilosopherStone.setText("jButton1");
FindPhilosopherStone.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
FindPhilosopherStone.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
FindPhilosopherStone.addActionListener(new java.awt.event.ActionListener() {
......@@ -1372,7 +1370,6 @@ public class MainPage extends javax.swing.JFrame {
});
FindManaCrystal.setIcon(new javax.swing.ImageIcon(getClass().getResource("/inventory/images/manaCrystal.PNG"))); // NOI18N
FindManaCrystal.setText("jButton1");
FindManaCrystal.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
FindManaCrystal.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
FindManaCrystal.addActionListener(new java.awt.event.ActionListener() {
......@@ -1382,7 +1379,6 @@ public class MainPage extends javax.swing.JFrame {
});
FindLifeElixir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/inventory/images/lifeElixir.PNG"))); // NOI18N
FindLifeElixir.setText("jButton1");
FindLifeElixir.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
FindLifeElixir.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
FindLifeElixir.addActionListener(new java.awt.event.ActionListener() {
......@@ -1392,7 +1388,6 @@ public class MainPage extends javax.swing.JFrame {
});
FindGems.setIcon(new javax.swing.ImageIcon(getClass().getResource("/inventory/images/gems.PNG"))); // NOI18N
FindGems.setText("jButton1");
FindGems.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
FindGems.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
FindGems.addActionListener(new java.awt.event.ActionListener() {
......@@ -1402,7 +1397,6 @@ public class MainPage extends javax.swing.JFrame {
});
FindIncense.setIcon(new javax.swing.ImageIcon(getClass().getResource("/inventory/images/incense.PNG"))); // NOI18N
FindIncense.setText("jButton1");
FindIncense.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
FindIncense.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
FindIncense.addActionListener(new java.awt.event.ActionListener() {
......@@ -1442,13 +1436,13 @@ public class MainPage extends javax.swing.JFrame {
FindItemLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(FindItemLayout.createSequentialGroup()
.addContainerGap()
.addGroup(FindItemLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(FindPotion)
.addComponent(FindHoney)
.addComponent(FindHerbs)
.addComponent(FindClay, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(FindMineral))
.addGap(18, 18, 18)
.addGroup(FindItemLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(FindPotion, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(FindHoney, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(FindHerbs, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(FindMineral, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(FindClay, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(36, 36, 36)
.addGroup(FindItemLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(FindIncense)
.addComponent(FindGems)
......@@ -1498,23 +1492,32 @@ public class MainPage extends javax.swing.JFrame {
.addGroup(finditemPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(FindIcon)
.addComponent(Find))
.addGap(0, 165, Short.MAX_VALUE))
.addGap(0, 174, Short.MAX_VALUE))
);
MainPanel.add(finditemPanel, "FindItemCard");
javax.swing.GroupLayout tradeitemPanelLayout = new javax.swing.GroupLayout(tradeitemPanel);
tradeitemPanel.setLayout(tradeitemPanelLayout);
tradeitemPanelLayout.setHorizontalGroup(
tradeitemPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 908, Short.MAX_VALUE)
FindOfferItemTable.setModel(tradeboxModel);
FindOfferItemScrollPane.setViewportView(FindOfferItemTable);
javax.swing.GroupLayout FindOfferItemPanelLayout = new javax.swing.GroupLayout(FindOfferItemPanel);
FindOfferItemPanel.setLayout(FindOfferItemPanelLayout);
FindOfferItemPanelLayout.setHorizontalGroup(
FindOfferItemPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(FindOfferItemPanelLayout.createSequentialGroup()
.addGap(19, 19, 19)
.addComponent(FindOfferItemScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 847, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(42, Short.MAX_VALUE))
);
tradeitemPanelLayout.setVerticalGroup(
tradeitemPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 540, Short.MAX_VALUE)
FindOfferItemPanelLayout.setVerticalGroup(
FindOfferItemPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, FindOfferItemPanelLayout.createSequentialGroup()
.addContainerGap(20, Short.MAX_VALUE)
.addComponent(FindOfferItemScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 500, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(20, 20, 20))
);
MainPanel.add(tradeitemPanel, "TradeItemCard");
MainPanel.add(FindOfferItemPanel, "TradeItemCard");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
......@@ -2205,17 +2208,9 @@ public class MainPage extends javax.swing.JFrame {
private void FindActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_FindActionPerformed
// TODO add your handling code here:
try {
//JSONObject response = client.sendFind(client.token,FindId);
/*if(response.get("status").equals("ok")) {
CardLayout cl = (CardLayout) MainPanel.getLayout();
cl.show(MainPanel, "TradeItemCard");
}*/
}
catch(Exception e) {
e.printStackTrace();
}
generateFindOfferTable();
CardLayout cl = (CardLayout) MainPanel.getLayout();
cl.show(MainPanel, "TradeItemCard");
}//GEN-LAST:event_FindActionPerformed
private void fieldButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fieldButtonActionPerformed
......@@ -2293,6 +2288,61 @@ public class MainPage extends javax.swing.JFrame {
}
}
private void generateFindOfferTable() {
try {
JSONObject response = client.sendFind(client.token,FindId);
if(response.getString("status").equals("ok")) {
JSONArray offer = response.getJSONArray("offers");
int dimX=offer.length();
int dimY=5;
FindOfferBoxModel =new TradeboxTableModel(dimX, dimY);
for(int i=0;i<offer.length();i++)
{
ImageIcon newPlayerIcon = getImage(offer.getJSONArray(i).getInt(0), 100, 100);
FindOfferBoxModel.setValueAt(newPlayerIcon, i, 0);
FindOfferBoxModel.setValueAt(offer.getJSONArray(i).get(1), i, 1);
newPlayerIcon = getImage(offer.getJSONArray(i).getInt(2), 100, 100);
FindOfferBoxModel.setValueAt(newPlayerIcon, i, 2);
FindOfferBoxModel.setValueAt(offer.getJSONArray(i).get(3), i, 3);
if(offer.getJSONArray(i).get(4).toString().equals("true")){ //avalaible
FindOfferBoxModel.setValueAt("Buy", i, 4);
}
}
FindOfferItemTable.setModel(FindOfferBoxModel);
FindOfferItemTable.setRowHeight(100);
Action delete = new AbstractAction()
{
public void actionPerformed(ActionEvent e)
{
JTable table = (JTable)e.getSource();
int modelRow = Integer.valueOf( e.getActionCommand() );
try {
if(offer.getJSONArray(modelRow).get(4).toString().equals("true"))
{
String offerToken=offer.getJSONArray(modelRow).get(5).toString();
sendAccept(offerToken);
}
} catch (JSONException ex) {
System.out.println("mouse click json Exception");
Logger.getLogger(MainPage.class.getName()).log(Level.SEVERE, null, ex);
}
}
};
ButtonColumn buttonColumn = new ButtonColumn(FindOfferItemTable, delete, 4);
buttonColumn.setMnemonic(KeyEvent.VK_D);
} else {
showMessage("Cannot find item. Try again later..");
}
} catch (Exception ex) {
showMessage("Server does not respond. Please try again later..");
System.out.println("FindItem Exception");
Logger.getLogger(MainPage.class.getName()).log(Level.SEVERE, null, ex);
}
}
private void generateTradebox(){
try {
JSONObject response = client.tradebox();
......@@ -2311,7 +2361,6 @@ public class MainPage extends javax.swing.JFrame {
newPlayerIcon = getImage(offer.getJSONArray(i).getInt(2), 100, 100);
tradeboxModel.setValueAt(newPlayerIcon, i, 2);
tradeboxModel.setValueAt(offer.getJSONArray(i).get(3), i, 3);
if(offer.getJSONArray(i).get(4).toString().equals("true")){ //avalaible
tradeboxModel.setValueAt("Cancel", i, 4);
}else{
......@@ -2354,6 +2403,7 @@ public class MainPage extends javax.swing.JFrame {
}
}
private ImageIcon getImage(int id, int width, int height)
{
String image="";
......@@ -2378,6 +2428,25 @@ public class MainPage extends javax.swing.JFrame {
return newIcon;
}
private void sendAccept(String offerToken) {
try {
JSONObject response = client.sendAccept(offerToken);
if(response.getString("status").equals("ok")){
showMessage("Item will be traded");
generateFindOfferTable();
}else if(response.getString("status").equals("fail")){
showMessage(response.getString("description"));
}else{
showMessage(response.getString("status"));
}
} catch (Exception ex) {
showMessage("Server does not respond. Please try again later..");
System.out.println("Send Accept Item Exception");
Logger.getLogger(MainPage.class.getName()).log(Level.SEVERE, null, ex);
}
}
private void fetchItem(String offerToken)
{
......@@ -2471,6 +2540,9 @@ public class MainPage extends javax.swing.JFrame {
private javax.swing.JButton FindLifeElixir;
private javax.swing.JButton FindManaCrystal;
private javax.swing.JButton FindMineral;
private javax.swing.JPanel FindOfferItemPanel;
private javax.swing.JScrollPane FindOfferItemScrollPane;
private javax.swing.JTable FindOfferItemTable;
private javax.swing.JButton FindPhilosopherStone;
private javax.swing.JButton FindPotion;
private javax.swing.JLabel GemsIcon;
......@@ -2566,6 +2638,7 @@ public class MainPage extends javax.swing.JFrame {
private javax.swing.JPanel tradeboxPanel;
private javax.swing.JScrollPane tradeboxScrollPane;
private javax.swing.JTable tradeboxTable;
private javax.swing.JLabel usernameLoginLabel;
private javax.swing.JPanel tradeitemPanel;
private javax.swing.JTextField usernameLoginTextField;
private javax.swing.JLabel usernameRegisterLabel;
......
......@@ -256,6 +256,7 @@ public class TCPClient {
return obj;
}
public JSONObject sendFind(String token,int FindId) throws Exception {
openConnection();
......
......@@ -5,4 +5,4 @@ do.jar=true
javac.debug=true
javadoc.preview=true
user.properties.file=C:\\Users\\Stephen\\AppData\\Roaming\\NetBeans\\8.0.2\\build.properties
\ No newline at end of file
user.properties.file=C:\\Users\\Stephen\\AppData\\Roaming\\NetBeans\\8.0.2\\build.properties
......@@ -299,6 +299,7 @@ public class TCPServer implements Runnable {
}
public JSONObject sendfind(JSONObject clientObject) throws JSONException, UnknownHostException, IOException {
System.out.println("masuk find");
if(clientObject.getString("token").equalsIgnoreCase(token)) {
// isi findOfferTime dengan waktu sekarang
DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
......@@ -347,6 +348,7 @@ public class TCPServer implements Runnable {
inFromServer.read(b);
String response = new String(b, "UTF-8");
System.out.println(response);
JSONObject tempResponse = new JSONObject(response);
if(tempResponse.getString("status").equalsIgnoreCase("ok")) {
......@@ -355,6 +357,7 @@ public class TCPServer implements Runnable {
offers.put(tempResponse.getJSONArray("offers").get(i));
offerHost.add(new Host(server.ipAddress, server.port));
}
}
}
......@@ -374,6 +377,7 @@ public class TCPServer implements Runnable {
return sql.sendfind(clientObject.getInt("item"));
}
} else {
System.out.println("error oi");
JSONObject responseJSON = new JSONObject();
responseJSON.put("status", "error");
return responseJSON;
......
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