Margin display

This commit is contained in:
7u83 2018-12-31 14:12:02 +01:00
parent 3a01f672eb
commit f7c2b6266e
2 changed files with 17 additions and 11 deletions

View File

@ -36,9 +36,10 @@
<Component class="javax.swing.JTable" name="assetTable">
<Properties>
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor">
<Table columnCount="2" rowCount="2">
<Table columnCount="3" rowCount="2">
<Column editable="false" title="Asset" type="java.lang.String"/>
<Column editable="false" title="Ammount" type="java.lang.String"/>
<Column editable="false" title="Margin" type="java.lang.String"/>
</Table>
</Property>
<Property name="columnModel" type="javax.swing.table.TableColumnModel" editor="org.netbeans.modules.form.editors2.TableColumnModelEditor">

View File

@ -36,14 +36,14 @@ import opensesim.world.Account;
*
* @author tube
*/
public class AccountPanel extends javax.swing.JPanel implements EventListener{
public class AccountPanel extends javax.swing.JPanel implements EventListener {
/**
* Creates new form AccountPanel
*/
public AccountPanel() {
initComponents();
assetTable.setAutoCreateRowSorter(true);
assetTable.setAutoCreateRowSorter(true);
assetTable.getTableHeader().setReorderingAllowed(false);
}
@ -54,17 +54,22 @@ public class AccountPanel extends javax.swing.JPanel implements EventListener{
model = (DefaultTableModel) this.assetTable.getModel();
Map<AbstractAsset, Double> am = account.getAssets();
int row = 0;
model.setRowCount(am.size());
for (AbstractAsset a : am.keySet()) {
Double val = account.get(a);
Double avail = account.getAvail(a);
String astr = val.toString()+"/"+avail.toString();
String astr = val.toString() + "/" + avail.toString();
Double mval = account.getMargin(a);
Double mavail = account.getAvail(a);
String mastr = mval.toString(); // + "/" + mavail.toString();
// model.setValueAt(ob1.getAccount().getOwner().getName(), row, 0);
model.setValueAt(a.getSymbol(), row, 0);
model.setValueAt(astr, row, 1);
model.setValueAt(mastr, row, 2);
row++;
}
@ -84,18 +89,18 @@ public class AccountPanel extends javax.swing.JPanel implements EventListener{
assetTable.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null},
{null, null}
{null, null, null},
{null, null, null}
},
new String [] {
"Asset", "Ammount"
"Asset", "Ammount", "Margin"
}
) {
Class[] types = new Class [] {
java.lang.String.class, java.lang.String.class
java.lang.String.class, java.lang.String.class, java.lang.String.class
};
boolean[] canEdit = new boolean [] {
false, false
false, false, false
};
public Class getColumnClass(int columnIndex) {