🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: JComboBox ItemStateChanged event fires twice

#13064
From: Jan Vasternas
Date: Thu, 01 Oct 1998 00:00
36 lines
1566 bytes
I think you could try to:

  void jComboBox1_itemStateChanged(ItemEvent e) {
    System.out.println("Begin jComboBox1_itemStateChanged");

    if ( e.getStateChange() == e.SELECTED ) {
         // this will only happens once per selection
         // Do whatever you want to do
    }

    System.out.println("End   jComboBox1_itemStateChanged");
  }

This way you dont do anything when the "DESELECT" event fires.

or

 you could listen for the ActionEvent instead, it only fires ones.

jan

Michael J. Olenik wrote in message <36139CE7.85C4A49E@prc.com>...
>When I use the "ItemStateChanged" event in the JCombobox to see if
>another item has been selected, I notice that the event fires TWICE.
>
>Can anyone lend some insight into why this happens and more importantly
>can it be stopped it from firing twice when the State Changes?
>
>I have noticed that the "PropertyChange" even fires only once, so maybe
>this is the correct event to look at.
>
>I have included a sample applet to demonstrate this.
>
>Thanks
>
>MIke
Technical Details
Message-ID: <6v0fjp$1oc4@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <36139CE7.85C4A49E@prc.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,b0f282afd51a5eac
X-Google-Attributes: gid111d45,public
From: "Jan Vasternas" <jan@vasternas.se>
Subject: Re: JComboBox ItemStateChanged event fires twice
Date: 1998/10/01
Message-ID: <6v0fjp$1oc4@forums.borland.com>
X-Deja-AN: 396762401
References: <36139CE7.85C4A49E@prc.com>
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.2106.4
Organization: Another Netscape Collabra Server User
Newsgroups: borland.public.jbuilder.java.swing