diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatClientProperties.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatClientProperties.java index 3e3e87ec..7011e39c 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatClientProperties.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatClientProperties.java @@ -181,6 +181,15 @@ public interface FlatClientProperties */ String POPUP_DROP_SHADOW_PAINTED = "Popup.dropShadowPainted"; + /** + * Specifies whether a heavy weight window should be used if the component is shown in a popup + * or if the component is the owner of another component that is shown in a popup. + *

+ * Component {@link javax.swing.JComponent}
+ * Value type {@link java.lang.Boolean} + */ + String POPUP_FORCE_HEAVY_WEIGHT = "Popup.forceHeavyWeight"; + //---- JProgressBar ------------------------------------------------------- /** 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 bf1fcd24..b04a744c 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 @@ -68,19 +68,17 @@ public class FlatPopupFactory y = pt.y; } - if( !isDropShadowPainted( owner, contents ) ) - return new NonFlashingPopup( getPopupForScreenOfOwner( owner, contents, x, y, false ), contents ); + boolean forceHeavyWeight = isOptionEnabled( owner, contents, FlatClientProperties.POPUP_FORCE_HEAVY_WEIGHT, "Popup.forceHeavyWeight" ); + + if( !isOptionEnabled( owner, contents, FlatClientProperties.POPUP_DROP_SHADOW_PAINTED, "Popup.dropShadowPainted" ) ) + return new NonFlashingPopup( getPopupForScreenOfOwner( owner, contents, x, y, forceHeavyWeight ), contents ); // macOS and Linux adds drop shadow to heavy weight popups - if( SystemInfo.isMacOS || SystemInfo.isLinux ) { - Popup popup = getPopupForScreenOfOwner( owner, contents, x, y, true ); - if( popup == null ) - popup = getPopupForScreenOfOwner( owner, contents, x, y, false ); - return new NonFlashingPopup( popup, contents ); - } + if( SystemInfo.isMacOS || SystemInfo.isLinux ) + return new NonFlashingPopup( getPopupForScreenOfOwner( owner, contents, x, y, true ), contents ); // create drop shadow popup - return new DropShadowPopup( getPopupForScreenOfOwner( owner, contents, x, y, false ), owner, contents ); + return new DropShadowPopup( getPopupForScreenOfOwner( owner, contents, x, y, forceHeavyWeight ), owner, contents ); } /** @@ -155,24 +153,20 @@ public class FlatPopupFactory popup.show(); } - private boolean isDropShadowPainted( Component owner, Component contents ) { - Boolean b = isDropShadowPainted( owner ); - if( b != null ) - return b; + private boolean isOptionEnabled( Component owner, Component contents, String clientKey, String uiKey ) { + if( owner instanceof JComponent ) { + Boolean b = FlatClientProperties.clientPropertyBooleanStrict( (JComponent) owner, clientKey, null ); + if( b != null ) + return b; + } - b = isDropShadowPainted( contents ); - if( b != null ) - return b; + if( contents instanceof JComponent ) { + Boolean b = FlatClientProperties.clientPropertyBooleanStrict( (JComponent) contents, clientKey, null ); + if( b != null ) + return b; + } - return UIManager.getBoolean( "Popup.dropShadowPainted" ); - } - - private Boolean isDropShadowPainted( Component c ) { - if( !(c instanceof JComponent) ) - return null; - - Object value = ((JComponent)c).getClientProperty( FlatClientProperties.POPUP_DROP_SHADOW_PAINTED ); - return (value instanceof Boolean ) ? (Boolean) value : null; + return UIManager.getBoolean( uiKey ); } /**