Performing an action after a RowSort operation

I have JTableand TableRowSorterwhich I would like to perform after surgery after . I am browsing the web and still have no luck.

Initially, I thought it would just RowSorterListenerperform the trick, but unfortunately it does not perform the operation after the sorting is complete.

Adding a header MouseListenerto JTablemay work, but the solution is not very elegant.

Does anyone have any ideas?

Thanks a bunch!


Change (of comments): In a method within a custom class TableModelis added as follows: AbstractTableModel. This method is called whenever JTableset / specified in a user class TableModel.

sorter.addRowSorterListener(new RowSorterListener() {
    @Override public void sorterChanged(RowSorterEvent rowsorterevent) {
        rebuildMItems(); // The method which executes
    }
});
+3
1

:

  • , RowSorter. sort()?

    , :

    @Override
    public void sort() {
        super.sort();
        doSomethingAfterSortingIsDone();
    }
    

    ?

  • ( RowSorterListener) : SORT_ORDER_CHANGED SORTED. type ?

+3

Source: https://habr.com/ru/post/1710348/


All Articles