mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-10 22:17:13 -06:00
Demo: on macOS use apple.awt.fullWindowContent and apple.awt.transparentTitleBar
This commit is contained in:
@@ -89,6 +89,24 @@ class DemoFrame
|
||||
|
||||
// do not use HTML text on macOS
|
||||
htmlMenuItem.setText( "some text" );
|
||||
|
||||
// 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
|
||||
toolBar.add( Box.createHorizontalStrut( 70 ), 0 );
|
||||
}
|
||||
|
||||
// enable full screen mode for this window
|
||||
getRootPane().putClientProperty( "apple.awt.fullscreenable", true );
|
||||
}
|
||||
|
||||
// integrate into macOS screen menu
|
||||
|
||||
@@ -38,6 +38,8 @@ public class FlatLafDemo
|
||||
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" );
|
||||
@@ -51,6 +53,7 @@ public class FlatLafDemo
|
||||
// - "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" );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user