This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

FYI: Patch: javax.swing


Hi list,


I just commited the attached fixes for javax.swing to merge them from 
classpath.


Michael


2004-01-28  Michael Koch  <konqueror@gmx.de>

	* javax/swing/JComponent.java
	(listenerList): Initalize globally.
	(ancestor_list): Removed.
	(veto_list): Removed.
	(change_list): Removed.
	(get_veto_list): Removed.
	(get_change_list): Removed.
	(get_ancestor_list): Removed.
	(removeAncestorListener): Reimplemented.
	(removePropertyChangeListener): Likewise.
	(removeVetoableChangeListener): Likewise.
	(addAncestorListener): Likewise.
	(addPropertyChangeListener): Likewise.
	(addVetoableChangeListener): Likewise.
	(getListeners): New method.
	(getAncestorListeners): Likewise.
	(getVetoableChangeListeners): Likewise.
	(fireVetoableChange): Throws PropertyVetoException.
	* javax/swing/JEditorPane.java
	(JEditorPane): Throws IOException.

Index: javax/swing/JComponent.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/JComponent.java,v
retrieving revision 1.5
diff -u -b -B -r1.5 JComponent.java
--- javax/swing/JComponent.java	22 Jan 2004 09:54:15 -0000	1.5
+++ javax/swing/JComponent.java	28 Jan 2004 19:35:44 -0000
@@ -1,5 +1,5 @@
 /* JComponent.java -- Every component in swing inherits from this class.
-   Copyright (C) 2002 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -63,8 +63,9 @@
 import java.beans.PropertyVetoException;
 import java.beans.VetoableChangeListener;
 import java.io.Serializable;
-import java.util.Vector;
+import java.util.EventListener;
 import java.util.Hashtable;
+import java.util.Vector;
 import javax.accessibility.Accessible;
 import javax.accessibility.AccessibleContext;
 import javax.accessibility.AccessibleExtendedComponent;
@@ -86,6 +87,9 @@
 public abstract class JComponent extends Container implements Serializable
 {
   static final long serialVersionUID = -5242478962609715464L;
+
+  protected EventListenerList listenerList = new EventListenerList();
+
         /**
          * accessibleContext
          */
@@ -98,9 +102,6 @@
 	boolean use_double_buffer, opaque;
 	protected ComponentUI ui;
 
-	Vector ancestor_list;
-	Vector veto_list;
-	Vector change_list;
 	Hashtable prop_hash;
 
 	/**
@@ -273,16 +274,12 @@
 		super();
 		super.setLayout(new FlowLayout());
 		
-		listenerList = new EventListenerList();
-    
 		//eventMask |= AWTEvent.COMP_KEY_EVENT_MASK;
 		// enableEvents( AWTEvent.KEY_EVENT_MASK );
 
 		//updateUI(); // get a proper ui
 	}
 
-	protected EventListenerList listenerList;
-
 	public boolean contains(int x, int y)
 	{
 		//return dims.contains(x,y);
@@ -301,24 +298,6 @@
 			prop_hash = new Hashtable();
 		return prop_hash;
 	}
-	public Vector get_veto_list()
-	{
-		if (veto_list == null)
-			veto_list = new Vector();
-		return veto_list;
-	}
-	public Vector get_change_list()
-	{
-		if (change_list == null)
-			change_list = new Vector();
-		return change_list;
-	}
-	public Vector get_ancestor_list()
-	{
-		if (ancestor_list == null)
-			ancestor_list = new Vector();
-		return ancestor_list;
-	}
 
 	public Object getClientProperty(Object key)
         {	return get_prop_hash().get(key);    }
@@ -326,29 +305,99 @@
 	public void putClientProperty(Object key, Object value)
 	{    get_prop_hash().put(key, value);   }
 
+  /**
+   * Unregister an <code>AncestorListener</code>.
+   */
 	public void removeAncestorListener(AncestorListener listener)
-	{  get_ancestor_list().removeElement(listener);  }
+  {
+    listenerList.remove(AncestorListener.class, listener);
+  }
 
+  /**
+   * Unregister a <code>PropertyChangeListener</code>.
+   */
         public void removePropertyChangeListener(PropertyChangeListener listener)
-	{  get_change_list().removeElement(listener);   }
+  {
+    listenerList.remove(PropertyChangeListener.class, listener);
+  }
 
+  /**
+   * Unregister a <code>PropertyChangeListener</code>.
+   */
 	public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
-	{  /* FIXME */   get_change_list().removeElement(listener);   }
+  {
+    listenerList.remove(PropertyChangeListener.class, listener);
+  }
 
+  /**
+   * Unregister a <code>VetoableChangeChangeListener</code>.
+   */
 	public void removeVetoableChangeListener(VetoableChangeListener listener)
-	{  get_veto_list().removeElement(listener);   }
+  {
+    listenerList.remove(VetoableChangeListener.class, listener);
+  }
 
+  /**
+   * Register an <code>AncestorListener</code>.
+   */
 	public void addAncestorListener(AncestorListener listener)
-	{   get_ancestor_list().addElement(listener);  }
+  {
+    listenerList.add(AncestorListener.class, listener);
+  }
 
+  /**
+   * Register a <code>PropertyChangeListener</code>.
+   */
 	public void addPropertyChangeListener(PropertyChangeListener listener)
-	{  get_change_list().addElement(listener);   }
+  {
+    listenerList.add(PropertyChangeListener.class, listener);
+  }
 
+  /**
+   * Register a <code>PropertyChangeListener</code>.
+   */
 	public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
-	{ /* FIXME */ get_change_list().addElement(listener);   }
+  {
+    listenerList.add(PropertyChangeListener.class, listener);
+  }
 
+  /**
+   * Register a <code>VetoableChangeListener</code>.
+   */
 	public void addVetoableChangeListener(VetoableChangeListener listener)
-	{  get_veto_list().addElement(listener);    }
+  {
+    listenerList.add(VetoableChangeListener.class, listener);
+  }
+
+  /**
+   * Return all registered listeners of a special type.
+   * 
+   * @since 1.3
+   */
+  public EventListener[] getListeners (Class listenerType)
+  {
+    return listenerList.getListeners (listenerType);
+  }
+  
+  /**
+   * Return all registered <code>Ancestor</code> objects.
+   * 
+   * @since 1.4
+   */
+  public AncestorListener[] getAncestorListeners()
+  {
+    return (AncestorListener[]) getListeners (AncestorListener.class);
+  }
+
+  /**
+   * Return all registered <code>VetoableChangeListener</code> objects.
+   * 
+   * @since 1.4
+   */
+  public VetoableChangeListener[] getVetoableChangeListeners()
+  {
+    return (VetoableChangeListener[]) getListeners (VetoableChangeListener.class);
+  }
 
 	public void computeVisibleRect(Rectangle rect)
 	{
@@ -397,6 +446,7 @@
 	}
 
 	protected  void fireVetoableChange(String propertyName, Object oldValue, Object newValue)
+          throws PropertyVetoException
 	{
 		//       Support for reporting constrained property changes.
 	}
Index: javax/swing/JEditorPane.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/JEditorPane.java,v
retrieving revision 1.2
diff -u -b -B -r1.2 JEditorPane.java
--- javax/swing/JEditorPane.java	11 Jun 2003 13:20:39 -0000	1.2
+++ javax/swing/JEditorPane.java	28 Jan 2004 19:35:44 -0000
@@ -1,5 +1,5 @@
 /* JEditorPane.java -- 
-   Copyright (C) 2002 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -41,6 +41,7 @@
 import java.awt.Dimension;
 import java.awt.event.KeyEvent;
 import java.io.InputStream;
+import java.io.IOException;
 import java.net.URL;
 import javax.accessibility.AccessibleContext;
 import javax.swing.text.EditorKit;
@@ -63,6 +64,7 @@
     }
 
     public JEditorPane(String url)
+      throws IOException
     {
 	this();
 	setPage(url);
@@ -75,6 +77,7 @@
     }
     
     public JEditorPane(URL url)
+      throws IOException
     {
 	setPage(url);
     }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]