diff --git a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/DemoFrame.java b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/DemoFrame.java index d802e4c4..fc367330 100644 --- a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/DemoFrame.java +++ b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/DemoFrame.java @@ -105,8 +105,9 @@ class DemoFrame toolBar.add( Box.createHorizontalStrut( 70 ), 0 ); } - // enable full screen mode for this window - getRootPane().putClientProperty( "apple.awt.fullscreenable", true ); + // enable full screen mode for this window (for Java 8 - 10; not necessary for Java 11+) + if( !SystemInfo.isJava_11_orLater ) + getRootPane().putClientProperty( "apple.awt.fullscreenable", true ); } // integrate into macOS screen menu diff --git a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatLafThemeEditor.java b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatLafThemeEditor.java index 41987d9e..aca916b1 100644 --- a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatLafThemeEditor.java +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatLafThemeEditor.java @@ -28,6 +28,8 @@ public class FlatLafThemeEditor public static void main( String[] args ) { // macOS if( SystemInfo.isMacOS ) { + // see https://www.formdev.com/flatlaf/macos/ + // enable screen menu bar // (moves menu bar from JFrame window to top of screen) System.setProperty( "apple.laf.useScreenMenuBar", "true" ); @@ -41,6 +43,7 @@ public class FlatLafThemeEditor // - "system": use current macOS appearance (light or dark) // - "NSAppearanceNameAqua": use light appearance // - "NSAppearanceNameDarkAqua": use dark appearance + // (needs to be set on main thread; setting it on AWT thread does not work) System.setProperty( "apple.awt.application.appearance", "system" ); } diff --git a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemeFileEditor.java b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemeFileEditor.java index 87d5a289..cdde8ad7 100644 --- a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemeFileEditor.java +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemeFileEditor.java @@ -177,6 +177,25 @@ class FlatThemeFileEditor if( SystemInfo.isMacOS ) { exitMenuItem.setVisible( false ); aboutMenuItem.setVisible( false ); + + // see https://www.formdev.com/flatlaf/macos/ + if( SystemInfo.isMacFullWindowContentSupported ) { + getRootPane().putClientProperty( "apple.awt.fullWindowContent", true ); + getRootPane().putClientProperty( "apple.awt.transparentTitleBar", true ); + + // hide window title + if( SystemInfo.isJava_17_orLater ) + getRootPane().putClientProperty( "apple.awt.windowTitleVisible", false ); + else + setTitle( null ); + + // add gap to left side of toolbar + controlPanel.add( Box.createHorizontalStrut( 70 ), 0 ); + } + + // enable full screen mode for this window (for Java 8 - 10; not necessary for Java 11+) + if( !SystemInfo.isJava_11_orLater ) + getRootPane().putClientProperty( "apple.awt.fullscreenable", false ); } // integrate into macOS screen menu