Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with selection in JTable  RSS feed

 
Patrik Nilsson
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am having a problem that I hope someone can help me with.

I have a JTable with products and wants to select the last chosen product when I get back to the page containing the table.
To select the productobject I have created my own renderer that draws a border around the product when it is selected.

I use aProductTable.changeSelection(vRow, vCol, false, false); and it scrolls to the right position but it never draws it as selected(with a border).
If I add a sleep(1) before changing selection it draws the border so it seems to have something to do with the table not being fully painted yet or something similar.

I check that I draw in the EDT.

Any help greatly appreciated
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if it works OK with a sleep(1), try it like this



depending on the scope of vRow and vCol, they may need to be 'final'
 
Patrik Nilsson
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have that already, I thought that should work that's why I am confused.

It is really hard to put some meaningful code exampel here so I am looking for a general tip what could be wrong but maybe that's too hard to guesss without some code.

Here is a part of my code at least:

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!