Results 1 to 3 of 3
- 04-26-2009, 12:52 PM #1
Member
- Join Date
- Apr 2009
- Posts
- 1
- Rep Power
- 0
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, 04: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
Similar Threads
-
Java, Military Format using "/" and "%" Operator!!
By sk8rsam77 in forum New To JavaReplies: 11Last Post: 02-26-2010, 03:03 AM -
Facing issue in printing user like "ab\\cd"
By psmhelp in forum New To JavaReplies: 4Last Post: 04-27-2009, 01:28 PM -
MoneyOut.println("It took you (whats wrong?>",year,"<WW?) years to repay the loan")
By soc86 in forum New To JavaReplies: 2Last Post: 01-24-2009, 06:56 PM -
Can't get my "if" statement to read user input
By daletron3030 in forum New To JavaReplies: 7Last Post: 01-16-2009, 05:24 AM -
the dollar sign "$", prints like any other normal char in java like "a" or "*" ?
By lse123 in forum New To JavaReplies: 1Last Post: 10-20-2008, 07:35 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks