0

I have a jTable in netbeans that is abstract and contains several columns like code, name, location, gravity, etc. I already have the code for this part, but I want to sort only a few columns such as name and severity. I do not know if anyone can help me, I will leave below the part of code I have to order the table.

public void sort() {
    TableRowSorter<DefaultTableModel> sorter = new TableRowSorter<DefaultTableModel>(modeloTabela);
    tabelaDoentes.setRowSorter(sorter);
    sort();
}
camickr
  • 321,443
  • 19
  • 166
  • 288
  • Does this answer your question? [How do I prevent a Java Swing JTable column from being sorted when the user click on the header?](https://stackoverflow.com/questions/14365510/how-do-i-prevent-a-java-swing-jtable-column-from-being-sorted-when-the-user-clic) – MarsAtomic Jun 03 '20 at 00:40
  • Read the API for the `TableRowSorter` and `DefaultRowSorter` for an appropriate method. While reading the API you will find the method you need and you might also find other useful methods for future requirements. – camickr Jun 03 '20 at 01:18

0 Answers0