This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: [PATCH] fixes to swing button implementation
- From: Michael Koch <konqueror at gmx dot de>
- To: Sascha Brawer <brawer at dandelis dot ch>
- Cc: GNU Classpath <classpath at gnu dot org>, graydon hoare <graydon at redhat dot com>, java-patches at gcc dot gnu dot org
- Date: Tue, 6 Jan 2004 22:27:25 +0100
- Subject: Re: [PATCH] fixes to swing button implementation
- References: <3FFB1521.1060302@redhat.com> <20040106211704.22283@smtp.mail.ch.easynet.net>
On Tue, Jan 06, 2004 at 10:17:04PM +0100, Sascha Brawer wrote:
> graydon hoare <graydon@redhat.com> wrote on Tue, 6 Jan 2004 15:05:53 -0500:
>
> >+ // ChangeEvents are not AWTEvents, can't use multicaster
> >+ Vector changeListeners = new Vector ();
>
> Using Vector means a lot of synchronization operations.
> java.util.ArrayList/LinkedList are not synchronized, which makes their
> usage more efficient. But probably, it would best tp use
> javax.swing.event.EventListenerList here (which, by coincidence, became
> functional this afternoon...). See the Javadoc in Classpath for how to
> use it efficiently. Or, for a more concrete example of its use, have a
> look at the method javax.swing.DefaultBoundedRangeModel.fireStateChanged.
>
> A general stylistic question: foo ().bar (baz) or foo().bar(baz)?
>
> AbstractButton.getMargin(): I'm not sure whether or not it should return
> a clone of the internal Insets object... A simple Mauve testcase could
> check for this.
>
> >Index: javax/swing/DefaultButtonModel.java
> >===================================================================
> >+ ActionListener actionListener;
> >+ ItemListener itemListener;
> >+
> >+ // ChangeEvents are not AWTEvents
> >+ Vector changeListeners = new Vector ();
>
> See above: it probably would be advisable to use
> javax.swing.event.EventListenerList instead of Vector.
The EventListenerList stuff is already on my disc since some time for
most JContainer subclasses. I said graydon not to do it.
Michael