public synchronized void setModel(StockTable model) { // we pass the model to the JTable this.table.setModel(model); // we set the first column to be larger (it contains the stock_name) TableColumn col = table.getColumnModel().getColumn(0); col.setPreferredWidth(250); // we add a sorter to the JTable (and we listen for sort changes, see below) TableRowSorter<StockTable> trs = new TableRowSorter<StockTable>(model); trs.addRowSorterListener(new SortListener()); table.setRowSorter(trs); }