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 221a069e..3475d114 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatClientProperties.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatClientProperties.java @@ -252,8 +252,15 @@ public interface FlatClientProperties String USE_WINDOW_DECORATIONS = "JRootPane.useWindowDecorations"; /** - * Specifies whether the menu bar is embedded into the title pane if custom - * window decorations are enabled. Default is {@code true}. + * Specifies whether the menu bar is embedded into the window title pane + * if window decorations are enabled. + *
+ * Setting this enables/disables embedding + * for the window that contains the root pane. + *
+ * This client property has lower priority than system property + * {@link FlatSystemProperties#MENUBAR_EMBEDDED}, but higher priority + * than UI default {@code TitlePane.menuBarEmbedded}. *
* (requires Window 10) *
diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatSystemProperties.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatSystemProperties.java index 8dd0149c..5397983a 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatSystemProperties.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatSystemProperties.java @@ -59,8 +59,7 @@ public interface FlatSystemProperties * when creating {@code JFrame} or {@code JDialog}. *
* Setting this to {@code true} forces using native window decorations - * even if they are not enabled by the application. - *
+ * even if they are not enabled by the application.
* Setting this to {@code false} disables using native window decorations.
*
* This system property has higher priority than client property @@ -92,12 +91,20 @@ public interface FlatSystemProperties String USE_JETBRAINS_CUSTOM_DECORATIONS = "flatlaf.useJetBrainsCustomDecorations"; /** - * Specifies whether menubar is embedded into custom window decorations. + * Specifies whether the menu bar is embedded into the window title pane + * if window decorations are enabled. + *
+ * Setting this to {@code true} forces embedding.
+ * Setting this to {@code false} disables embedding.
+ *
+ * This system property has higher priority than client property + * {@link FlatClientProperties#MENU_BAR_EMBEDDED} and + * UI default {@code TitlePane.menuBarEmbedded}. *
* (requires Window 10) *
* Allowed Values {@code false} and {@code true}
- * Default {@code true}
+ * Default none
*/
String MENUBAR_EMBEDDED = "flatlaf.menuBarEmbedded";
diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatNativeWindowBorder.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatNativeWindowBorder.java
index 688bfbfe..4d4afab1 100644
--- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatNativeWindowBorder.java
+++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatNativeWindowBorder.java
@@ -193,17 +193,11 @@ public class FlatNativeWindowBorder
}
private static boolean useWindowDecorations( JRootPane rootPane ) {
- // check whether forced to enabled/disabled via system property
- Boolean enabled = FlatSystemProperties.getBooleanStrict( FlatSystemProperties.USE_WINDOW_DECORATIONS, null );
- if( enabled != null )
- return enabled;
-
- // check whether forced to enabled/disabled via client property
- enabled = FlatClientProperties.clientPropertyBooleanStrict( rootPane, FlatClientProperties.USE_WINDOW_DECORATIONS, null );
- if( enabled != null )
- return enabled;
-
- return UIManager.getBoolean( "TitlePane.useWindowDecorations" );
+ return FlatUIUtils.getBoolean( rootPane,
+ FlatSystemProperties.USE_WINDOW_DECORATIONS,
+ FlatClientProperties.USE_WINDOW_DECORATIONS,
+ "TitlePane.useWindowDecorations",
+ false );
}
public static boolean hasCustomDecoration( Window window ) {
diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTitlePane.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTitlePane.java
index 05a0cb1c..3d843023 100644
--- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTitlePane.java
+++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTitlePane.java
@@ -429,9 +429,11 @@ public class FlatTitlePane
*/
protected boolean isMenuBarEmbedded() {
// not storing value of "TitlePane.menuBarEmbedded" in class to allow changing at runtime
- return UIManager.getBoolean( "TitlePane.menuBarEmbedded" ) &&
- FlatClientProperties.clientPropertyBoolean( rootPane, FlatClientProperties.MENU_BAR_EMBEDDED, true ) &&
- FlatSystemProperties.getBoolean( FlatSystemProperties.MENUBAR_EMBEDDED, true );
+ return FlatUIUtils.getBoolean( rootPane,
+ FlatSystemProperties.MENUBAR_EMBEDDED,
+ FlatClientProperties.MENU_BAR_EMBEDDED,
+ "TitlePane.menuBarEmbedded",
+ false );
}
protected Rectangle getMenuBarBounds() {
diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatUIUtils.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatUIUtils.java
index f9476443..c868af02 100644
--- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatUIUtils.java
+++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatUIUtils.java
@@ -54,6 +54,7 @@ import javax.swing.border.CompoundBorder;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.UIResource;
import com.formdev.flatlaf.FlatClientProperties;
+import com.formdev.flatlaf.FlatSystemProperties;
import com.formdev.flatlaf.util.DerivedColor;
import com.formdev.flatlaf.util.Graphics2DProxy;
import com.formdev.flatlaf.util.HiDPIUtils;
@@ -140,6 +141,25 @@ public class FlatUIUtils
return (value instanceof Number) ? ((Number)value).floatValue() : defaultValue;
}
+ /**
+ * @since 1.1.2
+ */
+ public static boolean getBoolean( JComponent c, String systemPropertyKey,
+ String clientPropertyKey, String uiKey, boolean defaultValue )
+ {
+ // check whether forced to true/false via system property
+ Boolean value = FlatSystemProperties.getBooleanStrict( systemPropertyKey, null );
+ if( value != null )
+ return value;
+
+ // check whether forced to true/false via client property
+ value = FlatClientProperties.clientPropertyBooleanStrict( c, clientPropertyKey, null );
+ if( value != null )
+ return value;
+
+ return getUIBoolean( uiKey, defaultValue );
+ }
+
public static boolean isChevron( String arrowType ) {
return !"triangle".equals( arrowType );
}