Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JTable rows focus highlighted  RSS feed

 
Arjun Shastry
Ranch Hand
Posts: 1906
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi All,
I am creating small swing application.Main panel contains JTable.From Find Menu, user opens Dialog and types a word to be seached.After clicking on Find button in Dialog, only those rows should be highlighted which contain the word to be searched.How to do this?

Thanks
 
Rob Camick
Ranch Hand
Posts: 2801
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to do what? You have multiple steps here and you haven't defined what step you are having a problem with. Do you know:

a) how to create a text field
b) how to get the text from the text field
c) how to create a table
c) search the TableModel one row at a time
d) use a ListSelectionModel to select a row

Or better yet do you know how to use a RowFilter so that the table will only display the rows with the selected text. Read the JTable API and follow the link to the Swing tutorial on "How to Use Tables" for a working example of filtering.
 
Arjun Shastry
Ranch Hand
Posts: 1906
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.Its step d, Searching the TableModel(hence dataVector) and highlighting those rows where word matches.I am using JDK 1.5.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!