• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

JTable: Get Row Index By Column(s) Value(s)

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I have a JTable with hundreds+ of rows of data. The user is able to move the columns and rows around, and delete/add rows and columns at will. The user cannot change the data, but individual cells are constantly updating from an outside source.

I need to be able to get the row index where columnA="x" and columnB="y"...and then update that one individual cell.

(for example, find the row where FirstName = "Jane", LastName ="Doe" and update the PointsEarned column.)

Is there anything built in to the default table model to do this? Since this table could update very very often, I need something relatively quick.

Any suggestions would be GREATLY appreciated!
 
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There's nothing built in.
You're going to want to search your TableModel. You could write a TableModel that indexes it's rows by column value. That would make searching very quick.

Personally though, I would go for the simple solution. 100 rows is really not very many at all. Just search your TableModel for the required values. If it turns out to be not fast enoguh you can optimise it later.

hth, D.
 
Jillian Kay
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks,I think that second answer is what I settled on yesterday, and you're right, if it isn't fast enough I can always go back and make that "find" method faster somehow.

Thanks for your advice! -Jillian
 
I didn't like the taste of tongue and it didn't like the taste of me. I will now try this tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic