Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 246959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T21:12:57+00:00 2026-05-11T21:12:57+00:00

I have a JTable and a TableRowSorter which I’d like to perform an operation

  • 0

I have a JTable and a TableRowSorter which I’d like to perform an operation after a sort is finished. I’ve been browsing the net, and so far I haven’t had much luck.

Initially I thought just a RowSorterListener would do the trick, but unfortunately it doesn’t perform the operation after the sort is finished.

Adding a MouseListener to the JTable header could work, but the solution isn’t terribly elegant.

Does anyone have any ideas?

Thanks a bunch!


Edit (from comment): The following is added in a method inside a custom TableModel class which extends AbstractTableModel. This method is invoked whenever the JTable is set/specified in the custom TableModel class.

sorter.addRowSorterListener(new RowSorterListener() {
    @Override public void sorterChanged(RowSorterEvent rowsorterevent) {
        rebuildMItems(); // The method which executes
    }
});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T21:12:57+00:00Added an answer on May 11, 2026 at 9:12 pm

    Two possibilities:

    1. I see you have a custom RowSorter. Couldn’t you simply add a call to your operation at the end of the sort() method?

      In other words, can you add this:

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

      to your sorter?

    2. Your current method (doing it in a RowSorterListener) performs the operation twice: once for SORT_ORDER_CHANGED and once for SORTED. Can you check the event’s type and only perform the operation at the correct time?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a JTable which has 1st row blank. Now when I sort the
I have a JTable to which I linked a DefaultTableModel and a TableRowSorter .
I have a Jtable on which I called the method table1.setAutoCreateRowSorter(true); . So this
I have a JTable that stores the results of a database query, so far
I have a JTable displays the event accordingly, I want to do like when
I have a JTable which uses a custom TableModel to display a series of
I have a JTable using a custom DefaultTableModel which has some Booleans in the
I am using a jtable which have 8 rows by default. When I add
I have a GUI which has a JComboBox and a JTable . The JComboBox
I have a JTable and a TableModel that extends AbstractTableModel . I would like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.