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



John St. Ledger wrote:

...I have some other controls. One JButton is labeled: "Set Default Input". A nice control to have. But when the user presses this button, up to 44 JComboBoxes have setSelectedItem () called on them, which fires at least 44 events, which in the action listeners sometimes call setSelectedItem() to make sure their "paired" JComboBox has a consistent selection, and these method calls fire still more events. I have JComboBoxes to insert layers, remove layers, and set the number of layers in the geology. I also have a button to set the inputs to the exact condition they had for a previous saved calculation. All of these involve calling setSelectedItem().

The problem here is that you're not using the ComboBox model. It has a setSelectedItem method that notifies the JComboBox to change it's displayed item. However this doesn't trigger an action event. It will trigger a ListDataEvent which will notify any other objects or models that the value has changed.

Scott has a different problem. He's trying to sync two models, the implicit one created behind each control and his own "document" model. That's more complicated. We solved that problem by extending the models for each type of control. Not particularly complicated really.

--Victor
_______________________________________________
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>)



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.