Article View: comp.lang.java.programmer
Article #415Re: ActionEvent on a JComboBox problem
From: Sandy Mustard
Date: Fri, 02 Jul 1999 00:00
Date: Fri, 02 Jul 1999 00:00
32 lines
1892 bytes
1892 bytes
A possible fix for this would be to remove the listener when you programatically set the value and then add it again. This way you don't need the boolean. On panel open, if you set the value before adding the listener, it won't be called. Sandy Mustard Stan Reinis wrote: > > We have a JComboBox on a JPanel. > > We need to call a method when the user changes the selected item > in the combobox. We have been using ActionEventListener to > accomplish this. However, if the combobox already has a value > assigned to it when the panel is opened, we do not want to call > this event. Unfortunately (for us), an ActionEvent is fired when > we programatically set the value in the combobox. > > To overcome this, we added a boolean that is set to false just before > we programatically change the value in the combobox. Then we change > it back. > > Occasionally it happens that the Action is processed before the boolean > changes. Apparently Actions are run on a different thread than the > main execution, which causes a race condition. > > What can we do here? > > Stan > Terren Corporation
Technical Details
Message-ID:
<377D14E1.B134C327@sdrc.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<377CF6DE.3049A54A@terren.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,a7b460689038b6b9 X-Google-Attributes: gidf74b3,public X-Google-Thread: 113ae9,a7b460689038b6b9 X-Google-Attributes: gid113ae9,public X-Google-Thread: 10a146,a7b460689038b6b9 X-Google-Attributes: gid10a146,public From: Sandy Mustard <sandy.mustard@sdrc.com> Subject: Re: ActionEvent on a JComboBox problem Date: 1999/07/02 Message-ID: <377D14E1.B134C327@sdrc.com> X-Deja-AN: 496534203 Distribution: world Content-Transfer-Encoding: 7bit References: <377CF6DE.3049A54A@terren.com> Content-Type: text/plain; charset=us-ascii Organization: Integration Services Mime-Version: 1.0 Newsgroups: comp.lang.java.programmer,comp.lang.java.help,borland.public.jbuilder.java.language