PopupFactory: fixed NullPointerException when PopupFactory.getPopup() is invoked with parameter owner set to null

This commit is contained in:
Karl Tauber
2021-02-13 13:31:30 +01:00
parent 4f00591c4e
commit 510ffd41d8
2 changed files with 7 additions and 4 deletions

View File

@@ -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

View File

@@ -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;