Results 1 to 3 of 3
- 04-26-2009, 01:52 PM #1Member
- Join Date
- Apr 2009
- Rep Power
differentiate between user selection and "additem" method in combobox
I'm trying to find a way for a JComboBox
action listener or item listener to differentiate between
the user making a selection and the invocation of methods
such as removeAllItems() and addItem(). As far as I've
been able to see, the ActionEvents and ItemEvents are
exactly the same.
I don't want actionperformed to be called in additem or removeallitems function.
I want actionperformed to be called when only user change combobox items.
How can I solve this problem?
One way (not sure if it's the best, but it works) is to remove all listeners prior to calling removeAllItems or addItem, and then re-add the listeners after these jobs have been complete.
- 04-28-2009, 05:52 AM #3
The ItemListener should only change if the selection changes, and not when adding/removing items.
You should be able to work out what triggered an event by looking at the ActionEvent or ItemEvent objects.Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
How To Ask Questions The Smart Way
- By sk8rsam77 in forum New To JavaReplies: 11Last Post: 02-26-2010, 04:03 AM
- By psmhelp in forum New To JavaReplies: 4Last Post: 04-27-2009, 02:28 PM
- By soc86 in forum New To JavaReplies: 2Last Post: 01-24-2009, 07:56 PM
- By daletron3030 in forum New To JavaReplies: 7Last Post: 01-16-2009, 06:24 AM
- By lse123 in forum New To JavaReplies: 1Last Post: 10-20-2008, 08:35 AM