🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #11168

Re: JComboBox and ActionListener

#11168
From: Peter
Date: Sun, 04 Jul 1999 00:00
64 lines
3389 bytes
ok...I will have to be more specific...I fully agree with what you said
BUT what I was trying to say - and obviously wasnt clear enough -
no matter what you do action is fired right at the creation of the component
...I have screen - JPanel ane few fields and combo boxes there and
when this panel is being created either action or item related actions
are fired right away....without me even touching'em.... and that seems
to be not desirable behaviour....... any comments to that?

Rich Wilkman wrote:

> Omer:
>
> ItemStateChanged will always be fired twice (and there are several other
> events in this pattern).  This is not a bug at all.  Here's what
> happens.
>
> You have a list with two items (it works the same with one, but it's
> easier to think about it with two items).  By default, one of them is
> selected and you click on the other one.  The item that was originally
> selected will fire a StateChanged because, well, it's state has changed
> to deselected.  The item you clicked on will fire the event for the
> reverse reason; it went from de-selected to selected.
>
> You need to dig a little deeper into the event.  If you only care about
> the widget that was selected check the event type/id and ignore it if
> the type was DESELECTED.  This doesn't stop the event from being fired
> twice, but it stops your code inside the event handler from being
> executed twice.
>
> -Rich
>
> Omer Azhar Qureshi wrote:
> >
> > Peter,
> > i had the same problem.... even the "itemStateChanged" event is fired twice
> > & when ever the selected item of the comboBox is changed whic was not
> > requied at all in my case as i had to get data from the servlet on the
> > itemChange which was done in a thread.... so subsequiently the thread was
> > called twice & the servlet as well which took a long time to trak down &
> > work around... ive search sun's site for such a bug report but there dosent
> > seem to be any....
> > ive not been able to restrict it from beeing called twice but i kinda fool
> > it the second time using an instance variable (boolean) & let it go on
> > alternate calls, but this is not a solution.... do post any solution that u
> > come up with....
> >
> > hope this helps
> > regards
> > Oaq
>
> --
>
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> Rich Wilkman
> Senior Quality Assurance Engineer
> Borland JBuilder Team
>
> If you see something that looks like an opinion up there,
> it's mine and mine alone.
>
> Mail sent to me from the newsgroups won't bounce but will
> be ignored.  If I have time, I'll respond, but you  have
> a better chance if you confine your posts to the newsgroups
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Technical Details
Message-ID: <377FB6B8.52E545D2@home.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <3770C13D.D349D879@terren.com> <7ksvat$c3111@forums.borland.com> <377261F0.E5A88B68@inprise.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,7f6f7d3b5376db9d
X-Google-Attributes: gid111d45,public
From: Peter <bliznak@home.com>
Subject: Re: JComboBox and ActionListener
Date: 1999/07/04
Message-ID: <377FB6B8.52E545D2@home.com>
X-Deja-AN: 497130300
Content-Transfer-Encoding: 7bit
References: <3770C13D.D349D879@terren.com> <7ksvat$c3111@forums.borland.com> <377261F0.E5A88B68@inprise.com>
X-Accept-Language: en
Content-Type: text/plain; charset=us-ascii
Organization: Another Netscape Collabra Server User
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.swing