• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

multiple selection in a JList

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Liar, liar, pants on fire! refreshing plug:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic