Although the EventTableModel takes care of
the table's rows, you must specify columns. This includes how many
columns, their names, and how to get the column value from an
Issue object. To specify columns, implement the
TableFormat interface.
import java.util.Comparator; // a simple issues library import ca.odell.issuezilla.*; // glazed lists import ca.odell.glazedlists.gui.TableFormat; /** * Display issues in a tabular form. * * @author <a href="mailto:jesse@odel.on.ca">Jesse Wilson</a> */ public class IssueTableFormat implements TableFormat { public int getColumnCount() { return 6; } public String getColumnName(int column) { if(column == 0) return "ID"; else if(column == 1) return "Type"; else if(column == 2) return "Priority"; else if(column == 3) return "State"; else if(column == 4) return "Result"; else if(column == 5) return "Summary"; throw new IllegalStateException(); } public Object getColumnValue(Object baseObject, int column) { Issue issue = (Issue)baseObject; if(column == 0) return issue.getId(); else if(column == 1) return issue.getIssueType(); else if(column == 2) return issue.getPriority(); else if(column == 3) return issue.getStatus(); else if(column == 4) return issue.getResolution(); else if(column == 5) return issue.getShortDescription(); throw new IllegalStateException(); } }
There are a few mixin interfaces that allow you to do more with
your table. WritableTableFormat allows you to
make your JTable editable.
AdvancedTableFormat allows you to specify the
class and a Comparator for each column, for use
with specialized renderers and
TableComparatorChooser.