Article View: borland.public.jbuilder.java.swing
Article #798Re: Action performed event handler fires twice
From: leov
Date: Wed, 30 Jun 2004 10:16
Date: Wed, 30 Jun 2004 10:16
20 lines
1499 bytes
1499 bytes
BrianW wrote:
> The problem is that the event handler is being called twice, so the text
> ends up in the text area twice. I read somewhere that it may be because the
> event handler doesn't register completion until the input stream has closed,
> so that the next time it checks for events, it hasn't been satisfied yet and
> gets fired again.
Right, because the ListSelectionEvent from the JComboBox fires twice,
first time for unselecting, second time for selecting the new item.
You can select just one by using the getValueIsAdjusting() method of the
event e.g.
doSomething(ListSelectionEvent e)
{
if (!e.getValueIsAdjusting()) justDoThatThing();
}
leo
Technical Details
Message-ID:
<2kfiblF1o5g8U1@uni-berlin.de>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!not-for-mailReferences:
<2k2icaF16gj6pU1@uni-berlin.de>Show Full Headers
Complete Article Headers
X-Google-Thread: 111d45,11c992ff0658e7ea X-Google-Attributes: gid111d45,public X-Google-Language: ENGLISH,ASCII-7-bit Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!not-for-mail From: leov <leov@emailaccount.com> Newsgroups: borland.public.jbuilder.java.swing Subject: Re: Action performed event handler fires twice Date: Wed, 30 Jun 2004 12:16:16 +0200 Lines: 20 Message-ID: <2kfiblF1o5g8U1@uni-berlin.de> References: <2k2icaF16gj6pU1@uni-berlin.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de ag4WDWWPkhIAG+FrnQqJMgIfQt2uEdFszTgaOUHdgcS6gveRw5 User-Agent: Mozilla Thunderbird 0.7 (Windows/20040616) X-Accept-Language: en-us, en In-Reply-To: <2k2icaF16gj6pU1@uni-berlin.de>