Author: heuermh
Date: Tue Oct  7 13:53:17 2008
New Revision: 396

Modified:
     
piccolo2d.java/trunk/extras/src/main/java/edu/umd/cs/piccolox/pswing/PSwing.java

Log:
Issue 20 ; adding ContainerAdapter to disable double-buffering in children  
added to a container after the container has been added to a PSwing  
component

Modified:  
piccolo2d.java/trunk/extras/src/main/java/edu/umd/cs/piccolox/pswing/PSwing.java
==============================================================================
---  
piccolo2d.java/trunk/extras/src/main/java/edu/umd/cs/piccolox/pswing/PSwing.java
         
(original)
+++  
piccolo2d.java/trunk/extras/src/main/java/edu/umd/cs/piccolox/pswing/PSwing.java
         
Tue Oct  7 13:53:17 2008
@@ -38,6 +38,8 @@
  import java.awt.*;
  import java.awt.event.ComponentAdapter;
  import java.awt.event.ComponentEvent;
+import java.awt.event.ContainerAdapter;
+import java.awt.event.ContainerEvent;
  import java.awt.geom.AffineTransform;
  import java.awt.geom.Rectangle2D;
  import java.awt.image.BufferedImage;
@@ -445,21 +447,24 @@
       * @param c The Component to be recursively unDoubleBuffered
       */
      void init( Component c ) {
-        Component[] children = null;
-        if( c instanceof Container ) {
-            children = ( (Container)c ).getComponents();
-        }
-
          if( c.getFont() != null ) {
              minFontSize = Math.min( minFontSize, c.getFont().getSize() );
          }

-        if( children != null ) {
-            for( int j = 0; j < children.length; j++ ) {
-                init( children[j] );
+        if (c instanceof Container) {
+            Component[] children = ((Container) c).getComponents();
+            if(children != null) {
+                for(int j = 0; j < children.length; j++) {
+                    init(children[j]);
+                }
              }
+            ((Container) c).addContainerListener(new ContainerAdapter() {
+                /** [EMAIL PROTECTED] */
+                public void componentAdded(final ContainerEvent event) {
+                    init(event.getChild());
+                }
+            });
          }
-
          if( c instanceof JComponent ) {
              ( (JComponent)c ).setDoubleBuffered( false );
              c.addPropertyChangeListener( "font", this );

--~--~---------~--~----~------------~-------~--~----~
Piccolo2D Developers Group: http://groups.google.com/group/piccolo2d-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to