Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to distinguish between user selection and programatic selection with ListSelectionListener



On Feb 6, 2004, at 4:52 PM, Jim Hagen wrote:

then update the UI. But not your document. And only update the UI through non-action-firing methods, i.e. JTextComponent.setText(..) or JComboBox.getModel.setSelectedItem(..)
...
OK. So here's the real answer : use JComboBox().getModel().setSelectedItem(..). Use JList.getListModel().setSelectedIndex(..). Buttons only fire actions on doClick(), you should using setSelected(), what's the issue there? Do you need a hidden button in the group to clear the selection, do you need to set the selected state for all of the buttons rather than running doClick() on just one, or is there some other issue??

Ok.. this was the simple thing that I was missing - that going straight to the model would avoid *some* of the events being fired. Do all Swing components work this way? Also sometimes the event that I'm interested in is not an Action event. I don't think list selection events work this way... (the subject of this thread). I have some experiments to do.

Just checking the source... the ListModel does not have a setSelectedIndex() method. Even the JList selection methods are delegated directly to the ListSelectionModel which fires the related events. It seems there is no way to avoid ListSelectionEvents.

Thanks for clearing this up. I'm not sure yet that it will solve all of the related issues, but it will solve some. I will post back if I find a particular case in my application that skipping the control an going direct to the model does not work for.

Scott
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Be sure to read the FAQ http://developer.apple.com/java/faq/ before posting
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: How to distinguish between user selection and programatic selection with ListSelectionListener (From: "John St. Ledger" <email@hidden>)
 >Re: How to distinguish between user selection and programatic selection with ListSelectionListener (From: Scott Palmer <email@hidden>)
 >Re: How to distinguish between user selection and programatic selection with ListSelectionListener (From: Jim Hagen <email@hidden>)
 >Re: How to distinguish between user selection and programatic selection with ListSelectionListener (From: Scott Palmer <email@hidden>)
 >Re: How to distinguish between user selection and programatic selection with ListSelectionListener (From: Jim Hagen <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.