• Post Reply Bookmark Topic Watch Topic
  • New Topic

JTable and it's selection listeners  RSS feed

 
Sebastiaan Kortleven
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
I've got me a nice JTable with some data in it.. Now I would like to get a popup window if I change a certain cell and select another row (popup window will only appear if changed data is not correct)..
So this is my code:

This piece of junk code gives me a headache...
These are the steps that are taken:
* Dubbelclick on a cell and edit it's data (wrongfully)
* Click on another row => popup appears => new row gets selected => popup appears again => row with wrongful data is selected
* Again, click on another row => other cell is selected (NOT row) => popup appears => row with wrongful data is selected
Why do I get 2 popups the first time, but only one the second time?
Perhaps a subquestion that might help me on my way..
The ListSelectionEvent is thrown each time I enter AND each time I leave a row? And if I manually set the selectioninterval, this event is thrown also?
Thanks in advance!
 
Fuqiang Zhao
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
add the code:
if(e.getValueIsAdjusting()) return;
after the code:
public void valueChanged(ListSelectionEvent e) {
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!