[kaffe] CVS kaffe (riccardo): fixed Containder add() methods
Kaffe CVS
cvs-commits at kaffe.org
Tue May 2 07:42:13 PDT 2006
PatchSet 7278
Date: 2006/05/02 14:32:28
Author: riccardo
Branch: HEAD
Tag: (none)
Log:
fixed Containder add() methods
Members:
ChangeLog:1.4782->1.4783
libraries/javalib/awt-implementations/kaffe/java/awt/Component.java:1.8->1.9
libraries/javalib/awt-implementations/kaffe/java/awt/Container.java:1.5->1.6
Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.4782 kaffe/ChangeLog:1.4783
--- kaffe/ChangeLog:1.4782 Wed Apr 26 19:22:04 2006
+++ kaffe/ChangeLog Tue May 2 14:32:28 2006
@@ -1,3 +1,9 @@
+2006-05-02 Riccardo Mottola <riccardo at kaffe.org>
+
+ * libraries/javalib/awt-implementations/kaffe/java/awt/Component.java,
+ libraries/javalib/awt-implementations/kaffe/java/awt/Container.java:
+ fixed Containder add() methods.
+
2006-04-26 Riccardo Mottola <riccardo at kaffe.org>
* libraries/javalib/awt-implementations/kaffe/java/awt/LayoutManager.java,
Index: kaffe/libraries/javalib/awt-implementations/kaffe/java/awt/Component.java
diff -u kaffe/libraries/javalib/awt-implementations/kaffe/java/awt/Component.java:1.8 kaffe/libraries/javalib/awt-implementations/kaffe/java/awt/Component.java:1.9
--- kaffe/libraries/javalib/awt-implementations/kaffe/java/awt/Component.java:1.8 Thu Apr 13 21:15:53 2006
+++ kaffe/libraries/javalib/awt-implementations/kaffe/java/awt/Component.java Tue May 2 14:32:32 2006
@@ -38,6 +38,7 @@
import java.awt.image.ImageObserver;
import java.awt.image.ImageProducer;
import java.awt.peer.ComponentPeer;
+import java.awt.peer.LightweightPeer;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.Serializable;
@@ -113,6 +114,9 @@
final static int IS_TEMP_HIDDEN = 0x20000;
final static int IS_SHOWING = IS_ADD_NOTIFIED | IS_PARENT_SHOWING | IS_VISIBLE;
+ /** The associated native peer. */
+ transient ComponentPeer peer;
+
/**
* Describes all registered PropertyChangeListeners.
*
@@ -547,10 +551,35 @@
return Toolkit.singleton.getScreenSize();
}
-// Subclasses that guarantee to always completely paint their contents should override this method and return true. All of the "heavyweight" AWT components are opaque.
-public boolean isOpaque() {
- return false;
-}
+ /**
+ * Tests if this component is opaque. All "heavyweight" (natively-drawn)
+ * components are opaque. A component is opaque if it draws all pixels in
+ * the bounds; a lightweight component is partially transparent if it lets
+ * pixels underneath show through. Subclasses that guarantee that all pixels
+ * will be drawn should override this.
+ *
+ * @return true if this is opaque
+ * @see #isLightweight()
+ * @since 1.2
+ */
+ public boolean isOpaque()
+ {
+ return ! isLightweight();
+ }
+
+ /**
+ * Return whether the component is lightweight. That means the component has
+ * no native peer, but is displayable. This applies to subclasses of
+ * Component not in this package, such as javax.swing.
+ *
+ * @return true if the component has a lightweight peer
+ * @see #isDisplayable()
+ * @since 1.2
+ */
+ public boolean isLightweight()
+ {
+ return peer instanceof LightweightPeer;
+ }
public Dimension getMinimumSize() {
return minimumSize();
Index: kaffe/libraries/javalib/awt-implementations/kaffe/java/awt/Container.java
diff -u kaffe/libraries/javalib/awt-implementations/kaffe/java/awt/Container.java:1.5 kaffe/libraries/javalib/awt-implementations/kaffe/java/awt/Container.java:1.6
--- kaffe/libraries/javalib/awt-implementations/kaffe/java/awt/Container.java:1.5 Tue Apr 25 22:33:30 2006
+++ kaffe/libraries/javalib/awt-implementations/kaffe/java/awt/Container.java Tue May 2 14:32:32 2006
@@ -35,41 +35,113 @@
Component[] component;
LayoutManager layoutMgr;
- ContainerListener cntrListener;
- Insets insets = Insets.noInsets;
+ /* Anything else is non-serializable, and should be declared "transient". */
+ transient ContainerListener containerListener;
+
+ // ContainerListener cntrListener;
+ Insets insets = Insets.noInsets;
protected Container () {
}
-public Component add (Component child) {
- add(child, null, -1);
- return (child);
-}
+ /**
+ * Adds the specified component to this container at the end of the
+ * component list.
+ *
+ * @param comp The component to add to the container.
+ *
+ * @return The same component that was added.
+ */
+ public Component add(Component comp)
+ {
+ addImpl(comp, null, -1);
+ return comp;
+ }
+
+ /**
+ * Adds the specified component to the container at the end of the
+ * component list. This method should not be used. Instead, use
+ * <code>add(Component, Object)</code>.
+ *
+ * @param name The name of the component to be added.
+ * @param comp The component to be added.
+ *
+ * @return The same component that was added.
+ *
+ * @see #add(Component,Object)
+ */
+ public Component add(String name, Component comp)
+ {
+ addImpl(comp, name, -1);
+ return comp;
+ }
-public void add(Component child, Object constraints) {
- // seems to be mapped to add(Component,Object,int) - since this is public
- // (and can be redefined) we have to do the same <sigh>
- add(child, constraints, -1);
-}
-public void add(Component child, Object constraints, int index) {
- addImpl(child, constraints, index);
-}
+ /**
+ * Adds the specified component to this container at the end of the
+ * component list. The layout manager will use the specified constraints
+ * when laying out this component.
+ *
+ * @param comp The component to be added to this container.
+ * @param constraints The layout constraints for this component.
+ */
+ public void add(Component comp, Object constraints)
+ {
+ addImpl(comp, constraints, -1);
+ }
+
+ /**
+ * Adds the specified component to this container at the specified index
+ * in the component list. The layout manager will use the specified
+ * constraints when layout out this component.
+ *
+ * @param comp The component to be added.
+ * @param constraints The layout constraints for this component.
+ * @param index The index in the component list to insert this child
+ * at, or -1 to add at the end of the list.
+ *
+ * @throws ArrayIndexOutOfBoundsException If the specified index is invalid.
+ */
+ public void add(Component comp, Object constraints, int index)
+ {
+ addImpl(comp, constraints, index);
+ }
+
+ /**
+ * Adds the specified component to this container at the specified index
+ * in the component list.
+ *
+ * @param comp The component to be added.
+ * @param index The index in the component list to insert this child
+ * at, or -1 to add at the end of the list.
+ *
+ * @return The same component that was added.
+ *
+ * @throws ArrayIndexOutOfBoundsException If the specified index is invalid.
+ */
+ public Component add(Component comp, int index)
+ {
+ addImpl(comp, null, index);
+ return comp;
+ }
-public Component add(Component child, int index) {
- add(child, null, index);
- return (child);
-}
-public Component add(String name, Component child) {
- add(child, name, -1);
- return (child);
-}
public void addContainerListener ( ContainerListener newListener ) {
- cntrListener = AWTEventMulticaster.add( cntrListener, newListener);
+ containerListener = AWTEventMulticaster.add( containerListener, newListener);
}
+ /**
+ * @since 1.4
+ */
+ public synchronized ContainerListener[] getContainerListeners()
+ {
+ return (ContainerListener[])
+ AWTEventMulticaster.getListeners(containerListener,
+ ContainerListener.class);
+ }
+
+
protected void addImpl(Component child, Object constraints, int index ) {
synchronized ( treeLock ) {
@@ -149,7 +221,7 @@
}
}
- if ( (cntrListener != null) || (eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0 ){
+ if ( (containerListener != null) || (eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0 ){
AWTEvent.sendEvent( ContainerEvt.getEvent( this,
ContainerEvent.COMPONENT_ADDED, child), false);
}
@@ -612,18 +684,18 @@
}
void process ( ContainerEvent e ) {
- if ( (cntrListener != null) || (eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0)
+ if ( (containerListener != null) || (eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0)
processEvent( e);
}
public void processContainerEvent ( ContainerEvent event ) {
- if ( cntrListener != null ) {
+ if ( containerListener != null ) {
switch ( event.getID() ) {
case ContainerEvent.COMPONENT_ADDED:
- cntrListener.componentAdded( event);
+ containerListener.componentAdded( event);
break;
case ContainerEvent.COMPONENT_REMOVED:
- cntrListener.componentRemoved( event);
+ containerListener.componentRemoved( event);
break;
}
}
@@ -760,7 +832,7 @@
component[n] = null;
ncomponents--;
- if ( (cntrListener != null) || (eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0 ){
+ if ( (containerListener != null) || (eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0 ){
AWTEvent.sendEvent( ContainerEvt.getEvent( this,
ContainerEvent.COMPONENT_REMOVED, c), false);
}
@@ -800,7 +872,7 @@
}
public void removeContainerListener ( ContainerListener listener ) {
- cntrListener = AWTEventMulticaster.remove( cntrListener, listener);
+ containerListener = AWTEventMulticaster.remove( containerListener, listener);
}
public void removeNotify() {
More information about the kaffe
mailing list