Theme Editor: on macOS use apple.awt.fullWindowContent and apple.awt.transparentTitleBar

This commit is contained in:
Karl Tauber
2022-05-05 13:20:23 +02:00
parent c3b9dc397d
commit 14932d3f07
3 changed files with 25 additions and 2 deletions

View File

@@ -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

View File

@@ -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" );
}

View File

@@ -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