Article View: borland.public.jbuilder.java.swing
Article #11679Re: Swing Event
From: John Smith
Date: Mon, 19 Apr 1999 00:00
Date: Mon, 19 Apr 1999 00:00
29 lines
2076 bytes
2076 bytes
i have experienced a similar problem a couple of times probably because of bad coding practice! - when dynamically creating components on the fly and then adding event listeners to these i found that sometimes when i re-instantiate and add the component to the screen in a single run that there is still an event listener registered with this component. i reckoned this was because i have not removed the event listener when removing the component, so that when the component appears again within the app, i re-add my event listener to that component and there are now two, or three etc event listeners listening, which will cause the associated event to fire multiple times etc. the simple solution is of course to instantiate the event listener that you are going to add with a name and then add/remove it by name when you add/remove the component from the gui - this fixed it for me. hope this was of help but i've not answered one of these before so i guess i might be talking twiddle! ta.. Bee Siu wrote in message <370C5AA2.F557BBBD@risingmore.com>... >Hi! > > I am using Swing components to create a GUI. I register a listener for >each component (e.g. FocusEventListener for JTextField, ItemListener for >JComboBox). However, I always receive the same event twice (and also the >same exception twice when error occurs!). I don't know why. Can someone >help me so solve this problem? Thanks! > >B
Technical Details
Message-ID:
<924512503.26644.0.nnrp-11.c1c3e175@news.demon.co.uk>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<370C5AA2.F557BBBD@risingmore.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,e598687ef57899eb X-Google-Attributes: gid111d45,public From: "John Smith" <r2@machine.head.com> Subject: Re: Swing Event Date: 1999/04/19 Message-ID: <924512503.26644.0.nnrp-11.c1c3e175@news.demon.co.uk> X-Deja-AN: 468224099 X-NNTP-Posting-Host: gavinc.eng.demon.net:193.195.225.117 References: <370C5AA2.F557BBBD@risingmore.com> X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 X-Complaints-To: abuse@demon.net X-Trace: news.demon.co.uk 924512503 nnrp-11:26644 NO-IDENT gavinc.eng.demon.net:193.195.225.117 Newsgroups: borland.public.jbuilder.java.swing