Methods Summary |
---|
public int | getColumnCount() return headers.length;
|
public java.lang.String | getColumnName(int c) return headers[c];
|
public int | getRowCount()
return stocks.length;
|
public java.lang.Object | getValueAt(int r, int c)
switch(c) {
case 0:
return stocks[r].symbol;
case 1:
return new Double(stocks[r].price);
case 2:
return new Double(stocks[r].delta);
case 3:
return stocks[r].lastUpdate;
}
throw new IllegalArgumentException("Bad cell (" + r + ", " + c +")");
|
public void | run()
while(true) {
// Blind update . . . we could check for real deltas if necessary
updateStocks();
// We know there are no new columns, so don't fire a data change, only
// fire a row update . . . this keeps the table from flashing
fireTableRowsUpdated(0, stocks.length - 1);
try { Thread.sleep(delay); }
catch(InterruptedException ie) {}
}
|
public void | setDelay(int seconds) delay = seconds * 1000;
|
public void | setStocks(int[] indices)
stockIndices = indices;
updateStocks();
fireTableDataChanged();
|
public void | updateStocks()
stocks = new Stock[stockIndices.length];
for (int i = 0; i < stocks.length; i++) {
stocks[i] = market.getQuote(stockIndices[i]);
}
|