Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ListSelectionListener getValueIsAdjusting()

 
Younes Essouabni
Ranch Hand
Posts: 479
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,
I have a JTable on which I added my own ListSelectionListener. I don't want to do any useless process while the user is choosing his row. I can get this behaviour with this method in my ListSelectionListener.

It is working perfectly fine if the user is selecting a row with the mouse. But if the user is selecting a row with the keyboard (which will probably be the default behaviour) the method getValueIsAdjusting never return true, and all the code not supposed to be processed, get processed many times. It leads to a drastic increasing of memory and a big slow down. How can I avoid this?
Thx in advance.
P.S: You may experiment it with this ListSelectionDemo. It has the same problem
[ January 23, 2003: Message edited by: Younes Essouabni ]
 
Younes Essouabni
Ranch Hand
Posts: 479
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this up, as I didn't found any answers.
Any help is welcome
Thx in advance
Younes
 
Younes Essouabni
Ranch Hand
Posts: 479
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe somebody could help me
Any guess is welcome
 
Eric Blische
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just a Guess but you might
try overriding getValueIsAdjusting()
in your ListSelectionListener object
to return a value more in league with
what you want to know ?
Eric
 
Eric Blische
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thinking about it for a minute it occurs to me the behavior SOUNDS to me to be right, the getValueIsAdjusting() should return true only if the event is indicative of a "temporary" list change, ie, if the focus passes to a popup menu and the like. So when you select a row with the keyboard, it is a "permanent" selection ... getValueIsAdjusting() should always return false (and you state it does). Maybe you problem can be solved by minimizing the work done when a row is selected, perhaps by caching, or another strategy to limit the overhead ?
Eric
 
Younes Essouabni
Ranch Hand
Posts: 479
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thx Eric for your answer. I just saw it, sorry
There is still something that I don't get.
...the getValueIsAdjusting() should return true only if the event is indicative of a "temporary" list change, ie, if the focus passes to a popup menu and the like...
Why would the focus be different if I select with my mouse or the keyboard? If you select a row with the mouse, the getValueIsAdjusting() return true until you release the mouse button. Why I don't have such a behaviour with my keyboard?
So maybe that the masters from Manning can help me. It's a long time that I'm praying for you to come preach in here
 
Matt Robinson
author
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This seems to be a bug. Whenever you are holding down CTRL or SHIFT (or their equivalents on other platforms), this method should return true because your selection is still in progress. I would work around this by overriding that method and returning true if either CTRL or SHIFT is currently down.
 
Younes Essouabni
Ranch Hand
Posts: 479
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thx Matt. In fact I never knew that I have to hold on CTRL or SHIFT. I tried it but nothing change. So, I will override the method and do nothing while the down array is pressed.
Thx a lot
 
Younes Essouabni
Ranch Hand
Posts: 479
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just for the case that anybody would need it later. I created a class that implements ListSelectionListener and KeyListener

It is working great for me, avoiding memory consumption. Thanx for all the help.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic