Article View: borland.public.jbuilder.java.swing
Article #13040Re: JComboBox not respond to event handler
From: John P. McGrath
Date: Sun, 27 Sep 1998 00:00
Date: Sun, 27 Sep 1998 00:00
33 lines
1712 bytes
1712 bytes
Andy Nguyen <nguyevu@turing.scs.carleton.ca> wrote: > My JComboBox has implemeted the "actionPerfomed" and the > "itemStateChanged" functions, but it seemed not responding. > You know why ? but the same codes embedding under the ChoiceControl > working fine. Since you did not post any code, I can only guess what your problem is. Events are only delivered to those objects that request them. If you have defined actionPerformed() and itemStateChanged() methods in a class you have derived from JComboBox, that is not all that is required to "catch" these events. You must also request that these methods be called. To receive an ActionEvent (i.e. to have actionPerformed() called) you must implement the ActionListener interface. This means you must add "implements ActionListener" to your class declaration, and define the actionPerformed() method, as required by the interface. Then you must call addActionListener() specifying the object that implements the interface. In your case, I believe you are doing this in the JComboBox derived class itself, so you would pass "this" as the argument to addActionListener(). -- Regards, John P. McGrath <mcgrath@enter.net> <jpm@nscs.fast.net>
Technical Details
Message-ID:
<MPG.1077dcc36899ddb49896bf@forums.inprise.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<3608F655.911685C9@turing.scs.carleton.ca>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,9e3c66d30758f1d X-Google-Attributes: gid111d45,public From: mcgrath@enter.net (John P. McGrath) Subject: Re: JComboBox not respond to event handler Date: 1998/09/27 Message-ID: <MPG.1077dcc36899ddb49896bf@forums.inprise.com> X-Deja-AN: 395284416 References: <3608F655.911685C9@turing.scs.carleton.ca> Organization: Software Consulting Services Newsgroups: borland.public.jbuilder.java.swing