macOS: improved macOS support of Demo and Theme Editor:

- set application name that is used in screen menu bar
- enable dark window title bars if macOS is in dark mode
This commit is contained in:
Karl Tauber
2021-10-24 17:05:50 +02:00
parent 78cef1b3c7
commit 3facbc0900
3 changed files with 36 additions and 6 deletions

View File

@@ -34,10 +34,24 @@ public class FlatLafDemo
static boolean screenshotsMode = Boolean.parseBoolean( System.getProperty( "flatlaf.demo.screenshotsMode" ) );
public static void main( String[] args ) {
// on macOS enable screen menu bar
if( SystemInfo.isMacOS && System.getProperty( "apple.laf.useScreenMenuBar" ) == null )
// macOS
if( SystemInfo.isMacOS ) {
// enable screen menu bar
// (moves menu bar from JFrame window to top of screen)
System.setProperty( "apple.laf.useScreenMenuBar", "true" );
// application name used in screen menu bar
// (in first menu after the "apple" menu)
System.setProperty( "apple.awt.application.name", "FlatLaf Demo" );
// appearance of window title bars
// possible values:
// - "system": use current macOS appearance (light or dark)
// - "NSAppearanceNameAqua": use light appearance
// - "NSAppearanceNameDarkAqua": use dark appearance
System.setProperty( "apple.awt.application.appearance", "system" );
}
if( FlatLafDemo.screenshotsMode && !SystemInfo.isJava_9_orLater && System.getProperty( "flatlaf.uiScale" ) == null )
System.setProperty( "flatlaf.uiScale", "2x" );

View File

@@ -16,6 +16,8 @@
package com.formdev.flatlaf.themeeditor;
import com.formdev.flatlaf.util.SystemInfo;
/**
* FlatLaf Theme Editor
*
@@ -24,6 +26,24 @@ package com.formdev.flatlaf.themeeditor;
public class FlatLafThemeEditor
{
public static void main( String[] args ) {
// macOS
if( SystemInfo.isMacOS ) {
// enable screen menu bar
// (moves menu bar from JFrame window to top of screen)
System.setProperty( "apple.laf.useScreenMenuBar", "true" );
// application name used in screen menu bar
// (in first menu after the "apple" menu)
System.setProperty( "apple.awt.application.name", "FlatLaf Theme Editor" );
// appearance of window title bars
// possible values:
// - "system": use current macOS appearance (light or dark)
// - "NSAppearanceNameAqua": use light appearance
// - "NSAppearanceNameDarkAqua": use dark appearance
System.setProperty( "apple.awt.application.appearance", "system" );
}
FlatThemeFileEditor.main( args );
}
}

View File

@@ -104,10 +104,6 @@ class FlatThemeFileEditor
Locale.setDefault( Locale.ENGLISH );
System.setProperty( "user.language", "en" );
// on macOS enable screen menu bar
if( SystemInfo.isMacOS )
System.setProperty( "apple.laf.useScreenMenuBar", "true" );
SwingUtilities.invokeLater( () -> {
FlatLaf.registerCustomDefaultsSource( "com.formdev.flatlaf.themeeditor" );