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 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 in that getModel() returns the list's data model and
the current selection isn't part of the data so the ListSelectionModel
is a more appropriate place to do this, but then the JComboBox methods
are inconsistent with this concept.

I think it's this inconsistency that makes things difficult. One could
wish for a more consistent API in the controls and their models -- but
the various controls aren't all that analogous to each other either and
wedging an API where it doesn't fit can also lead to obscurity.
A lesser of two evils decision?

Stephen


--
"Most Win32 programs utilize MFC, however, and MFC
is one horrendous pig."
- Jim Frost (http://world.std.com/~jimf/)
_______________________________________________
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: Scott Palmer <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.