From 6a8bf2acc55b5911ece3cf31ea5a975d1a3c4db7 Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Tue, 2 Jun 2020 16:07:11 +0200 Subject: [PATCH] FlatInspector: fixed highlight figure bounds of windows; limit used inspection level to existing components --- .../formdev/flatlaf/testing/FlatInspector.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatInspector.java b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatInspector.java index d0b9ec37..58a88d4c 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatInspector.java +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatInspector.java @@ -226,8 +226,13 @@ public class FlatInspector private void inspect( int x, int y ) { Point pt = SwingUtilities.convertPoint( rootPane.getGlassPane(), x, y, rootPane ); Component c = getDeepestComponentAt( rootPane, pt.x, pt.y ); - for( int i = 0; i < inspectParentLevel && c != null; i++ ) - c = c.getParent(); + for( int i = 0; i < inspectParentLevel && c != null; i++ ) { + Container parent = c.getParent(); + if( parent == null ) + break; + + c = parent; + } if( c == lastComponent ) return; @@ -279,9 +284,9 @@ public class FlatInspector highlightFigure.setVisible( c != null ); if( c != null ) { - Rectangle bounds = c.getBounds(); - Rectangle highlightBounds = SwingUtilities.convertRectangle( c.getParent(), bounds, rootPane ); - highlightFigure.setBounds( highlightBounds ); + highlightFigure.setBounds( new Rectangle( + SwingUtilities.convertPoint( c, 0, 0, rootPane ), + c.getSize() ) ); } }