• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

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
 
Every time you till, you lose 30% of your organic matter. But this tiny ad is durable:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic