mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-11 06:27:13 -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" ) );
|
static boolean screenshotsMode = Boolean.parseBoolean( System.getProperty( "flatlaf.demo.screenshotsMode" ) );
|
||||||
|
|
||||||
public static void main( String[] args ) {
|
public static void main( String[] args ) {
|
||||||
// on macOS enable screen menu bar
|
// macOS
|
||||||
if( SystemInfo.isMacOS && System.getProperty( "apple.laf.useScreenMenuBar" ) == null )
|
if( SystemInfo.isMacOS ) {
|
||||||
|
// enable screen menu bar
|
||||||
|
// (moves menu bar from JFrame window to top of screen)
|
||||||
System.setProperty( "apple.laf.useScreenMenuBar", "true" );
|
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 )
|
if( FlatLafDemo.screenshotsMode && !SystemInfo.isJava_9_orLater && System.getProperty( "flatlaf.uiScale" ) == null )
|
||||||
System.setProperty( "flatlaf.uiScale", "2x" );
|
System.setProperty( "flatlaf.uiScale", "2x" );
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package com.formdev.flatlaf.themeeditor;
|
package com.formdev.flatlaf.themeeditor;
|
||||||
|
|
||||||
|
import com.formdev.flatlaf.util.SystemInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FlatLaf Theme Editor
|
* FlatLaf Theme Editor
|
||||||
*
|
*
|
||||||
@@ -24,6 +26,24 @@ package com.formdev.flatlaf.themeeditor;
|
|||||||
public class FlatLafThemeEditor
|
public class FlatLafThemeEditor
|
||||||
{
|
{
|
||||||
public static void main( String[] args ) {
|
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 );
|
FlatThemeFileEditor.main( args );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,10 +104,6 @@ class FlatThemeFileEditor
|
|||||||
Locale.setDefault( Locale.ENGLISH );
|
Locale.setDefault( Locale.ENGLISH );
|
||||||
System.setProperty( "user.language", "en" );
|
System.setProperty( "user.language", "en" );
|
||||||
|
|
||||||
// on macOS enable screen menu bar
|
|
||||||
if( SystemInfo.isMacOS )
|
|
||||||
System.setProperty( "apple.laf.useScreenMenuBar", "true" );
|
|
||||||
|
|
||||||
SwingUtilities.invokeLater( () -> {
|
SwingUtilities.invokeLater( () -> {
|
||||||
FlatLaf.registerCustomDefaultsSource( "com.formdev.flatlaf.themeeditor" );
|
FlatLaf.registerCustomDefaultsSource( "com.formdev.flatlaf.themeeditor" );
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user