< prev index next >

src/java.desktop/share/classes/java/awt/Component.java

Print this page

        

@@ -1310,10 +1310,28 @@
     boolean isRecursivelyVisible() {
         return visible && (parent == null || parent.isRecursivelyVisible());
     }
 
     /**
+     * Determines the bounds which will be displayed on the screen.
+     *
+     * @return the visible part of bounds in the coordinate space of this comp
+     */
+    private Rectangle getRecursivelyVisibleBounds() {
+        final Component container = getContainer();
+        final Rectangle bounds = getBounds();
+        if (container == null) {
+            // we are top level window or haven't a container, return our bounds
+            return bounds;
+        }
+        // translate the container's bounds to our coordinate space
+        final Rectangle parentsBounds = container.getRecursivelyVisibleBounds();
+        parentsBounds.setLocation(0, 0);
+        return parentsBounds.intersection(bounds);
+    }
+
+    /**
      * Translates absolute coordinates into coordinates in the coordinate
      * space of this component.
      */
     Point pointRelativeToComponent(Point absolute) {
         Point compCoords = getLocationOnScreen();

@@ -1485,11 +1503,11 @@
             synchronized (getTreeLock()) {
                 enabled = true;
                 ComponentPeer peer = this.peer;
                 if (peer != null) {
                     peer.setEnabled(true);
-                    if (visible) {
+                    if (visible && !getRecursivelyVisibleBounds().isEmpty()) {
                         updateCursorImmediately();
                     }
                 }
             }
             if (accessibleContext != null) {

@@ -1539,11 +1557,11 @@
                     transferFocus(false);
                 }
                 ComponentPeer peer = this.peer;
                 if (peer != null) {
                     peer.setEnabled(false);
-                    if (visible) {
+                    if (visible && !getRecursivelyVisibleBounds().isEmpty()) {
                         updateCursorImmediately();
                     }
                 }
             }
             if (accessibleContext != null) {
< prev index next >