Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can't clear highlight in JTable cell

 
Thomas Fly
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After I click on cell(6, 3) to select that flight, and purchase my tickets, I reread from the database (according to the existing search criteria), and display the updated data.
However, cell(6, 3) will still have a highlight after I'm "done." clearSelection() methods don't seem to do anything... what's going on?
I can write an HTML background color into that cell to gloss over the problem, but that's a kludge.
 
Stephane Weber
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
In my case, after each booking I call a method 'refreshSearch' that will reread from database and update the display.
basically it contains this :

And this makes the selection disappear after the booking.
Hope this helps
Stephane
 
Thomas Fly
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm... thanks. I found that I can also do:but that still doesn't seem to address the issue surgically...
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whenever I had changes to maketo the JTable, I just created a new instance of my TableModel and used setTableModel method of the JTable, and that worked.
I never had to change or code change the row or column that was selected.
Mark
 
Thomas Fly
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, as an addendum:
I had been using j2sdk1.4, and only just converted to 1.3.
The problem disappeared entirely with 1.3...
but of course the fonts all now look like gopher poop.
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

but of course the fonts all now look like gopher poop.

Makes good fertilizer
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic