Revision: 973
Author: allain.lalonde
Date: Fri Feb 26 13:32:02 2010
Log: Fix for Issue 163 changes in size of node itself were being detected,
but not changes in the size of its progeny.
I'm not entirely sure why a method called "ancestorResized" gets called
when a subcomponent changes... but I'm not going to complain. Just works.
http://code.google.com/p/piccolo2d/source/detail?r=973
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
Tue Feb 2 11:20:47 2010
+++
/piccolo2d.java/trunk/extras/src/main/java/edu/umd/cs/piccolox/pswing/PSwing.java
Fri Feb 26 13:32:02 2010
@@ -42,6 +42,8 @@
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;
@@ -323,7 +325,13 @@
public void propertyChange(final PropertyChangeEvent evt) {
updateBounds();
}
- });
+ });
+ component.addHierarchyBoundsListener(new HierarchyBoundsAdapter() {
+ /** {...@inheritdoc} */
+ public void ancestorResized(HierarchyEvent arg0) {
+ updateBounds();
+ }
+ });
updateBounds();
listenForCanvas(this);
@@ -430,9 +438,9 @@
/** {...@inheritdoc} */
public void setVisible(final boolean visible) {
super.setVisible(visible);
-
+
if (component.isVisible() != visible) {
- component.setVisible(visible);
+ component.setVisible(visible);
}
}
@@ -643,8 +651,9 @@
}
if (newCanvas == null) {
- canvas = null;
- } else {
+ canvas = null;
+ }
+ else {
canvas = newCanvas;
canvas.addPSwing(this);
updateBounds();
--
Piccolo2D Developers Group: http://groups.google.com/group/piccolo2d-dev?hl=en