[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Wed, 28 Dec 2005 21:05:02 -0500
// if first and last index of the given ListDataEvent are both -1,
// then it indicates that selected item in the combo box data model
// have changed.
if (event.getIndex0() == -1 && event.getIndex1() == -1)
it handles when the indexes are both -1, but it doesn't seem to handle any
other case. Is this indeed the correct behavior? In particular, this seems
to break MetalFileChooserUI, because
DirectoryComboBoxModel.setSelectedItem() always calls fireContentsChanged
fireContentsChanged(this, 0, items.size() - 1);
So, basically, when the popup list calls JComboBox.setSelectedIndex(...),
JComboBox never calls selectedItemChanged(), which never lets the listeners
in MetalFileChooserUI know that the selected item has changed.
Does this seem right?
if (selectedItem == null)
if (object == null)
selectedItem = object;
fireContentsChanged(this, -1, -1);
which is why anything which uses the default model works.
Incidentally, if you modify contentsChanged to run selectedItemChanged() on
other than -1, -1, you seem to get an infinite loop. I think that this is
fixable, however, if you put checks into MetalFileChooserUI's
DirectoryComboBoxAction.actionPerformed to only change the directory and
rescan if something has actually changed. I haven't verified this yet,
"Let us endeavor so to live that when we come to die even the undertaker
will be sorry." -- Mark Twain, "Pudd'nhead Wilson's Calendar"
========== Evil Overlord Quote of the Day (www.eviloverlord.com) =========
217. If I'm wearing the key to the hero's shackles around my neck and his
former girlfriend now volunteers to become my mistress and we are all
alone in my bedchamber on my bed and she offers me a goblet of wine, I
will politely decline the offer.
|[Prev in Thread]
||[Next in Thread]|
Chris Lansdown <=