• Post Reply Bookmark Topic Watch Topic
  • New Topic

multiple selection in a JList

 
guenter krannich
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've got a JList, where I set


After pressing Ctrl, selecting one item, selecting a second item, releasing Ctrl I se that the valueChanged method was invoked twice (valueIsAdjusting==false):
the first time getFirstIndex and getLastIndex deliver the same index, the second time they are as expected.

I only expected the second event -was I wrong?
 
Ed Tidwell
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds right to me.

Your in the 'grey' area of event programming.

So for example when do you know when you have a double or triple mouse click?

There is actually a timer that gets set and if a single mouse click comes in before the timer expires it gets promoted. All OS windowing systems allow you to configure the defaults for this.

So when you clicked on the first item with a CTRL it STILL generated a single selection.

I hope this makes sense.

So the ignore changing check that you are doing should prevent LOTS of events from being generated when the user does a large SHIFT selection. You could think that each item added could generated an action selected event but this prevents it.

Test it with a shift selection and see what happens.

Hope this helps.

Ed
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!