I know that I JTablecan sort by one column. But is it possible to allow sorting multiple columns or do I need to write the code myself?
JTable
You can sort by multiple columns by specifying more than one sort key when calling setSortKeysin RowSorterwhich you are using.
setSortKeys
RowSorter
You should be able to install the associated TableRowSorter and Comparator. Example:
TableModel myModel = createMyTableModel(); JTable table = new JTable(myModel); TableRowSorter t = new TableRowSorter(myModel); t.setComparator(column that the comparator works against, Comparator<?> comparator); table.setRowSorter(new TableRowSorter(myModel));
JXTable. JXTable - JTable, , , JTable . JDNC/SwingLabs.
ETable netbeans.org-netbeans-swing-outline.jarGoogle google, . ETable Outline (TreeTable), , .
" , Jtable . ?"
Sorting and filtering the table is controlled by the sorter object. The easiest way to provide a sorter object is to set the autoCreateRowSorter property to true:
JTable table = new JTable(); table.setAutoCreateRowSorter(true);
This action defines the row sorter, which is an instance of javax.swing.table.TableRowSorter.