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

  • SEARCH
  • Home
  • 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 8085129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:00:58+00:00 2026-06-05T18:00:58+00:00

I am facing problem of duplicate rows in the JXTable . If I sort

  • 0

I am facing problem of duplicate rows in the JXTable. If I sort the JXTable data while the new rows are being inserted in JXTable, the final result in JXTable shows duplicate rows that make invalid result in table. Even it also shows correct count of rows that has been inserted but some rows are completely missing whereas some rows are found duplicate in JXTable.

If I sort the JXTable after all data has been inserted successfully then it is showing correct data i.e no duplicate rows and no rows missing.

code example :
I have a method to which I am passing defaultTableModel and here is am adding items in the table

public void addingItems(DefaultTableModel  defaultTableModel)
{
for(int i=0;i< numberofItems;i++){
Vector vobject = new Vector();
vobject.add("...");
vobject.add("xxx");
vobject.add("yyy");
...
..
vobject.add("");
defaultTableModel.addRow(vobject);
}

one the other hand I have adding code of sorting at tableHeader actionlistener

tableheader.addMouseListener(new MouseListener() {
 public void mouseClicked(MouseEvent e) {
     Vector data = defaultTableModel.getDataVector();   
     Collections.sort(data, new ColumnSorter(colIndex, ascending));
}

});

I have put code in the synchronized block but not getting success.

Please provide a better solution to handle this issue.

  • 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-06-05T18:00:59+00:00Added an answer on June 5, 2026 at 6:00 pm

    I have put code in the synchronized block but not getting success.

    Because you have to handle synchronization not only in your sort handler block, but also on each modification operation.

    For example:

      ... 
      vobject.add("");
      synchronized(monitor) {
        defaultTableModel.addRow(vobject);
      }
    }
    

    and

      ...
      Vector data = defaultTableModel.getDataVector();
      synchronized(monitor) {
        Collections.sort(data, new ColumnSorter(colIndex, ascending));
      }
    }
    

    In this case your UI could look somewhat unresponsive if you have a lot of data in your table because sort is N^2*logN. If you have somewhat about 200 entries – it wouldn’t make a problem for you.

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

Sidebar

Related Questions

Possible Duplicate: Parse C# string to DateTime I am facing a problem while converting
I am facing problem while generating CAB file. I want to customize the INF
I am new to struts 2. I am facing problem in filling Select tag
Facing a problem, it seems my data stored in SQL Server does not stored
Am facing a problem, while creating components through TOM API using .NET/COM Interop. Actual
I'm facing a problem that seems to have no straighforward solution. I'm using java.util.Map
Im facing problem when trying to apply data annotation. In my case im passing
I am facing problem in getting Facebook data I am using Facebook SDK for
I have facing problem in listview i am getting data from server and after
All, I'm new to XSLT and facing a typical problem. Below is the problem

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.