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 fdf79c20..5d624fe6 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatClientProperties.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatClientProperties.java @@ -103,6 +103,15 @@ public interface FlatClientProperties */ String MINIMUM_HEIGHT = "JComponent.minimumHeight"; + /** + * Specifies whether a drop shadow is painted 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_DROP_SHADOW_PAINTED = "Popup.dropShadowPainted";
+
/**
* Specifies whether the progress bar has always the larger height even if no string is painted.
*
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 8c27e006..379bde2c 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 @@ -31,6 +31,7 @@ import javax.swing.PopupFactory; import javax.swing.SwingUtilities; import javax.swing.UIManager; import javax.swing.border.Border; +import com.formdev.flatlaf.FlatClientProperties; import com.formdev.flatlaf.util.SystemInfo; /** @@ -50,7 +51,7 @@ public class FlatPopupFactory public Popup getPopup( Component owner, Component contents, int x, int y ) throws IllegalArgumentException { - if( !UIManager.getBoolean( "Popup.dropShadowPainted" ) ) + if( !isDropShadowPainted( owner, contents ) ) return super.getPopup( owner, contents, x, y ); // macOS and Linux adds drop shadow to heavy weight popups @@ -70,6 +71,26 @@ public class FlatPopupFactory return new DropShadowPopup( popup, owner, contents ); } + private boolean isDropShadowPainted( Component owner, Component contents ) { + Boolean b = isDropShadowPainted( owner ); + if( b != null ) + return b; + + b = isDropShadowPainted( contents ); + 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; + } + /** * There is no API in Java 8 to force creation of heavy weight popups, * but it is possible with reflection. Java 9 provides a new method.