diff --git a/CHANGELOG.md b/CHANGELOG.md index 18cdca94..cd40f1cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ FlatLaf Change Log in "Look in" combobox. (Windows 10 only; issue #249) - Table: Fixed wrong grid line thickness in dragged column on HiDPI screens on Java 9+. (issue #236) +- PopupFactory: Fixed `NullPointerException` when `PopupFactory.getPopup()` is + invoked with parameter `owner` set to `null`. ## 1.0-rc3 diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatPopupFactory.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatPopupFactory.java index 45199226..6ee90e3c 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatPopupFactory.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatPopupFactory.java @@ -62,7 +62,7 @@ public class FlatPopupFactory public Popup getPopup( Component owner, Component contents, int x, int y ) throws IllegalArgumentException { - Point pt = fixToolTipLocation( owner, contents, x, y ); + Point pt = fixToolTipLocation( contents, x, y ); if( pt != null ) { x = pt.x; y = pt.y; @@ -111,6 +111,7 @@ public class FlatPopupFactory // check whether heavy weight popup window is on same screen as owner component if( popupWindow == null || + owner == null || popupWindow.getGraphicsConfiguration() == owner.getGraphicsConfiguration() ) return popup; @@ -211,7 +212,7 @@ public class FlatPopupFactory * This method checks whether the current mouse location is within tooltip bounds * and corrects the y-location so that the tooltip is placed above the mouse location. */ - private Point fixToolTipLocation( Component owner, Component contents, int x, int y ) { + private Point fixToolTipLocation( Component contents, int x, int y ) { if( !(contents instanceof JToolTip) || !wasInvokedFromToolTipManager() ) return null; @@ -450,10 +451,10 @@ public class FlatPopupFactory mediumWeightShown = true; - Window window = SwingUtilities.windowForComponent( owner ); - if( window == null ) + if( owner == null ) return; + Window window = SwingUtilities.windowForComponent( owner ); if( !(window instanceof RootPaneContainer) ) return;