mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-27 03:46:17 -06:00
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:
@@ -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" );
|
||||
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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" );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user