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 9, 2004, at 5:05 PM, Stephen Paulsen wrote:

On Sunday, February 8, 2004, at 01:35 pm, Scott Palmer wrote:

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.


But the ListSelectionModel has setSelectionInterval

mylist.getSelectionModel().setSelectionInterval(n, n);

would set a single selected item at index n in the list.

This makes sense...

Well, yes, I know that... the point is that the selection model only has the single method to change the selection and so it always triggers the related events. There is no way to initialize the selection without having the listeners called... I understand that the View will want to get those events so that it could update, but if I simply ask the control repaint itself it will query the selection model anyway - as long as it gets the repaint signal somehow. But you are correct to point on the inconsistencies which means that a common solution for the various controls is possibly more complex than it needs to be.

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: Stephen Paulsen <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.