mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-06 14:00:55 +03:00
Popup: fixed NPE if GraphicsConfiguration is null on Windows (issue #921)
Some checks failed
CI / build (11, ) (push) Waiting to run
CI / build (17, ) (push) Waiting to run
CI / build (21, ) (push) Waiting to run
CI / build (23, ) (push) Waiting to run
CI / build (8, ) (push) Waiting to run
CI / snapshot (push) Blocked by required conditions
CI / release (push) Blocked by required conditions
Native Libraries / Natives (macos) (push) Waiting to run
Native Libraries / Natives (ubuntu) (push) Waiting to run
Native Libraries / Natives (windows) (push) Waiting to run
Fonts / Fonts (inter) (push) Has been cancelled
Fonts / Fonts (jetbrains-mono) (push) Has been cancelled
Fonts / Fonts (roboto) (push) Has been cancelled
Fonts / Fonts (roboto-mono) (push) Has been cancelled
Some checks failed
CI / build (11, ) (push) Waiting to run
CI / build (17, ) (push) Waiting to run
CI / build (21, ) (push) Waiting to run
CI / build (23, ) (push) Waiting to run
CI / build (8, ) (push) Waiting to run
CI / snapshot (push) Blocked by required conditions
CI / release (push) Blocked by required conditions
Native Libraries / Natives (macos) (push) Waiting to run
Native Libraries / Natives (ubuntu) (push) Waiting to run
Native Libraries / Natives (windows) (push) Waiting to run
Fonts / Fonts (inter) (push) Has been cancelled
Fonts / Fonts (jetbrains-mono) (push) Has been cancelled
Fonts / Fonts (roboto) (push) Has been cancelled
Fonts / Fonts (roboto-mono) (push) Has been cancelled
also check for null GraphicsConfiguration in other classes
This commit is contained in:
@@ -24,6 +24,7 @@ import java.awt.Dimension;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.Insets;
|
||||
import java.awt.KeyboardFocusManager;
|
||||
import java.awt.LayoutManager;
|
||||
@@ -450,15 +451,18 @@ public class FlatInspector
|
||||
Dimension size = tip.getPreferredSize();
|
||||
|
||||
// position the tip in the visible area
|
||||
Rectangle visibleRect = rootPane.getGraphicsConfiguration().getBounds();
|
||||
if( tx + size.width > visibleRect.x + visibleRect.width )
|
||||
tx -= size.width + UIScale.scale( 16 );
|
||||
if( ty + size.height > visibleRect.y + visibleRect.height )
|
||||
ty -= size.height + UIScale.scale( 32 );
|
||||
if( tx < visibleRect.x )
|
||||
tx = visibleRect.x;
|
||||
if( ty < visibleRect.y )
|
||||
ty = visibleRect.y;
|
||||
GraphicsConfiguration gc = rootPane.getGraphicsConfiguration();
|
||||
if( gc != null ) {
|
||||
Rectangle visibleRect = gc.getBounds();
|
||||
if( tx + size.width > visibleRect.x + visibleRect.width )
|
||||
tx -= size.width + UIScale.scale( 16 );
|
||||
if( ty + size.height > visibleRect.y + visibleRect.height )
|
||||
ty -= size.height + UIScale.scale( 32 );
|
||||
if( tx < visibleRect.x )
|
||||
tx = visibleRect.x;
|
||||
if( ty < visibleRect.y )
|
||||
ty = visibleRect.y;
|
||||
}
|
||||
|
||||
PopupFactory popupFactory = PopupFactory.getSharedInstance();
|
||||
popup = popupFactory.getPopup( c, tip, tx, ty );
|
||||
|
||||
Reference in New Issue
Block a user