Revision: 978
Author: cmal...@pixelzoom.com
Date: Mon Mar  8 10:35:45 2010
Log: Fixes issue 163.
- Removed the HiercharyBoundsListener that was added in r973, it was not totally effective, and it's not clear why it was partially effective. - Added component.revalidate to updateBounds, so that bounds are computed based on correct component size. - Removed redundant call to component.revalidate in constructor, since the constructor calls updateBounds.
http://code.google.com/p/piccolo2d/source/detail?r=978

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 Fri Feb 26 13:32:02 2010 +++ /piccolo2d.java/trunk/extras/src/main/java/edu/umd/cs/piccolox/pswing/PSwing.java Mon Mar 8 10:35:45 2010
@@ -42,8 +42,6 @@
 import java.awt.event.ContainerAdapter;
 import java.awt.event.ContainerEvent;
 import java.awt.event.ContainerListener;
-import java.awt.event.HierarchyBoundsAdapter;
-import java.awt.event.HierarchyEvent;
 import java.awt.geom.Rectangle2D;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
@@ -319,19 +317,13 @@
         component.putClientProperty(PSWING_PROPERTY, this);
         initializeComponent(component);

-        component.revalidate();
+ //TODO: this listener is suspicious, it's not listening for any specific property
         component.addPropertyChangeListener(new PropertyChangeListener() {
             /** {...@inheritdoc} */
             public void propertyChange(final PropertyChangeEvent evt) {
                 updateBounds();
             }
         });
-        component.addHierarchyBoundsListener(new HierarchyBoundsAdapter() {
-            /** {...@inheritdoc} */
-            public void ancestorResized(HierarchyEvent arg0) {
-                updateBounds();
-            }
-        });

         updateBounds();
         listenForCanvas(this);
@@ -356,6 +348,7 @@
         // TODO: should we make sure this is called at least once
// TODO: does this sometimes need to be called when size already equals
         // preferred size, to relayout/update things?
+        component.revalidate();
         if (componentNeedsResizing()) {
component.setBounds(0, 0, component.getPreferredSize().width, component.getPreferredSize().height);
         }

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

Reply via email to