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 3969442
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:57:51+00:00 2026-05-20T03:57:51+00:00

Here is how my data in jTable looks: SrNo Name LName 1 A B

  • 0

Here is how my data in jTable looks:

SrNo Name LName
1    A       B
2    B       C
3    D       E
4    F       G

now when I click row 4, and click a button “Move to TOP”, the table should look like this,

SrNo Name LName
1    F       G
2    A       B
3    B       C
4    D       E

I could think of two approaches:

  1. Swap(just content of Name and LName) row 4 with row 3, row 3 with row 2, do this till we reach to top.
  2. Change the SrNo of the row selected to 1, increase SrNo of all the rows above it, decrease the SrNo of all the rows below it and sort by SrNo.

Which is good approach? Or is there any better approach?

(This table is binded to database, but it is another problem)

  • 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-20T03:57:52+00:00Added an answer on May 20, 2026 at 3:57 am

    The DefaultTableModel already supports a moveRow(…) method.

    Also, I have no idea what the SrNo is, but if the value is just the row number then it should not be part of the model. Instead is should be rendered as part of the row header view. Maybe something like the Row Number Table.

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

Sidebar

Related Questions

last time I asked how to populate a data structure here . Now I
I have this structure: <JFrame> <JPanel backgroundcolor = pink> <JScrollPane> <JTable>!!!Data here !!!</JTable> </JScrollPane>
I'm downloaded the code from John Papa's book here: http://silverlight-data.com/ and am sucessfully running
ex: <a><strike>example data in here</strike></a> I want everything inside the a tag, to the
How can I represent the following in XSD. <price-update> <![CDATA[ arbitrary data goes here
Here is my Json data: [{ok : false, details : [{n : Email, v
Here is a sample code to retrieve data from a database using the yield
Here are two questions related to modifying the data source for strongly typed dataset
Here's the setup I have in a vs2008 solution: Data layer in a project
Here is some XAML <HierarchicalDataTemplate DataType={x:Type data:FolderEntity} ItemsSource={Binding Path=FolderEntities,UpdateSourceTrigger=PropertyChanged}> <Label Content={Binding FolderName}/> </HierarchicalDataTemplate> <TreeView/>

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.