Got it.
Java has made a total mess (IMNSHO) of this type of thing.
Can we all agree that a JList, which is a list of items, and a JComboBox (which is another sort of list), should generally behave the same way in terms of selection events that they throw?
Well anyways..
JComboBox - You can add an ItemListener, which requires you to define behaviour for when itemStateChange is called. This method is passed an ItemEvent, which you can then query as to its getStateChange() to determine whether the event is a lost-focus or gained-focus type of event. Or - I haven't tested it, but you can also add an ActionListener, which requires you to define behaviour for actionPerformed, which it would *hopefully* call only once (when you click the combobox?).
JList - You cannot use either ItemListener or ActionListener, but must use instead ListSelectionListener. This requires you to define behaviour for valueChanged. This method is passed a ListSelectionEvent, but you cannot query this type of event as to its getStateChange()
BUT. There is a getValueIsAdjusting() method you can call. If the answer is true, then most likely, the event is the first of the two events (the one where the 'previous' item is losing focus), and if it is false, it's probably the second event (the one where the 'current' item is gaining focus).
ARGH! It makes me wish for the simplicity (simple-minded?) VB!
I haven't done the "catch and release" behaviour that I did for the that other
thread I mentioned in my last post. But you can see from the println() what you need to check.
BTW: This code is umm... maybe changed enough to break the copyright of it's original writers.
[This message has been edited by Mike Curwen (edited March 29, 2001).]