FileDocCategorySizeDatePackage
AccountTableModel.javaAPI DocExample1245Thu Jun 27 19:20:22 BST 2002com.oreilly.mock

AccountTableModel

public class AccountTableModel extends AbstractTableModel

Fields Summary
public static final int
ACCT_TYPE_COL
public static final int
ACCT_BALANCE_COL
public static final int
ACCT_NUMBER_COL
private List
accounts
Constructors Summary
Methods Summary
public voidaddAccount(Account acct)

        int row = this.accounts.size();
        this.accounts.add(acct);
        fireTableRowsInserted(row, row);
    
public intgetColumnCount()

        return 3;
    
public intgetRowCount()


       
        return this.accounts.size();
    
public java.lang.ObjectgetValueAt(int rowIndex, int columnIndex)

        Account acct = (Account) this.accounts.get(rowIndex);
        switch (columnIndex) {
            case ACCT_BALANCE_COL:
                return new Double(acct.getBalance());
            case ACCT_NUMBER_COL:
                return acct.getAccountNumber();
            case ACCT_TYPE_COL:
                return new Integer(acct.getAccountType());
        }
        throw new IllegalArgumentException("Illegal column: "
                + columnIndex);