13.07.2015 Views

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

16.7 Getting Down to Cases: Designing a GUI for BudgetPro361Example 16.2 Defining our AbstractTableModel130 private Comp<strong>on</strong>ent131 createList()132 {133 JScrollPane retval;134135 model = new AbstractTableModel()136 {137 private String [] columnNames = {"Account", "Owner", "Value"};138139 public String140 getColumnName(int col) {141 return columnNames[col];142 } // getColumnName143144 public int145 getRowCount()146 {147 int retval;148149 if (current != null) {150 retval = current.size();151 } else {152 retval = 1; // testing <strong>on</strong>ly153 }154155 return retval;156157 } // getRowCount158159 public int getColumnCount() { return columnNames.length; }160161 public Object162 getValueAt(int row, int col) {163 Object retval = null;164 Account aa = null;165 // return "---"; // rowData[row][col];166 int count = 0;167 for (Iterator itr=current.getAllSubs(); itr.hasNext(); )168 {169 count++;170 aa = (Account) itr.next();171 if (count > row) { break; }172 } // next

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!