Article View: borland.public.jbuilder.java.api
Article #2198Re: Combo Box ItemStateChange -- Seems to Fire 2X Per Change!
From: Torsten Welches
Date: Mon, 23 Apr 2001 07:48
Date: Mon, 23 Apr 2001 07:48
37 lines
2150 bytes
2150 bytes
Harry,
it works as designed - you get one DESELECTED event for the
former and one SELECTED event for the new selcected item.
You can use ItemEvent.getStateChange() to distinguish the two
events.
Torsten
"Harry Whitehouse" <harry@envmgr.com> wrote:
>I must be missing a simple, basic concept WRT JComboBoxes. I have an applet
>which instantiates one combobox...
>
>JComboBox jComboBoxMailingType = new JComboBox();
>
>I add and item listener, and populate the combobox with a few selections.
>
> jComboBoxMailingType.addItemListener(new java.awt.event.ItemListener() {
> public void itemStateChanged(ItemEvent e) {
> jComboBoxMailingType_itemStateChanged(e);
> }
> });
>
>
>I've chosen to listen for itemStateChanged() which invokes a process....
>
>void jComboBoxMailingType_itemStateChanged(ItemEvent e) {
> DoSomeProcess();
>}
>
>Now the curious thing is I enter the event handler TWICE whenever I change
>the combobox selection. I'd expect to enter this handler function once per
>change in selection.
>
>Baiscally, I want to DoSomeProcess() once when the combobox selection
>changes to a new value. Can someone point out what I'm missing here?
Technical Details
Message-ID:
<3ae3de4a$1_1@dnews>Path:
arc1-ca.pugleaf.net!newsfeed.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!news.maxwell.syr.edu!colt.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnewsReferences:
<3ae3d70e_2@dnews>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1089d0,3b1cfaee1687958 X-Google-Attributes: gid1089d0,public X-Google-ArrivalTime: 2001-04-23 01:16:05 PST From: "Torsten Welches" <torsten.welches@who.cares.netcologne.de> Sender: "Torsten Welches" <torsten.welches@who.cares.netcologne.de> Reply-To: "Torsten Welches" <torsten.welches@who.cares.netcologne.de> Subject: Re: Combo Box ItemStateChange -- Seems to Fire 2X Per Change! Newsgroups: borland.public.jbuilder.java.api X-User-Info: 193.158.55.74 193.158.55.74 References: <3ae3d70e_2@dnews> NNTP-Posting-Host: 207.105.83.65 Message-ID: <3ae3de4a$1_1@dnews> Date: 23 Apr 2001 00:48:26 -0700 X-Trace: dnews 988012106 207.105.83.65 (23 Apr 2001 00:48:26 -0700) Lines: 38 Path: arc1-ca.pugleaf.net!newsfeed.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!news.maxwell.syr.edu!colt.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnews