mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-07 14:30:56 +03:00
added Flat*Laf.install() methods
This commit is contained in:
@@ -3,6 +3,7 @@ FlatLaf Change Log
|
||||
|
||||
## Unreleased
|
||||
|
||||
- Added `Flat*Laf.install()` methods.
|
||||
- macOS: Use native screen menu bar if system property
|
||||
`apple.laf.useScreenMenuBar` is `true`.
|
||||
|
||||
|
||||
@@ -24,6 +24,10 @@ package com.formdev.flatlaf;
|
||||
public class FlatDarculaLaf
|
||||
extends FlatDarkLaf
|
||||
{
|
||||
public static boolean install( ) {
|
||||
return install( new FlatDarculaLaf() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Flat Darcula";
|
||||
|
||||
@@ -24,6 +24,10 @@ package com.formdev.flatlaf;
|
||||
public class FlatDarkLaf
|
||||
extends FlatLaf
|
||||
{
|
||||
public static boolean install( ) {
|
||||
return install( new FlatDarkLaf() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Flat Dark";
|
||||
|
||||
@@ -24,6 +24,10 @@ package com.formdev.flatlaf;
|
||||
public class FlatIntelliJLaf
|
||||
extends FlatLightLaf
|
||||
{
|
||||
public static boolean install( ) {
|
||||
return install( new FlatIntelliJLaf() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Flat IntelliJ";
|
||||
|
||||
@@ -39,6 +39,7 @@ import java.util.function.Function;
|
||||
import javax.swing.AbstractButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JTabbedPane;
|
||||
import javax.swing.LookAndFeel;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.UIDefaults;
|
||||
import javax.swing.UIManager;
|
||||
@@ -73,6 +74,16 @@ public abstract class FlatLaf
|
||||
private AWTEventListener mnemonicListener;
|
||||
private static boolean altKeyPressed;
|
||||
|
||||
public static boolean install( LookAndFeel newLookAndFeel ) {
|
||||
try {
|
||||
UIManager.setLookAndFeel( newLookAndFeel );
|
||||
return true;
|
||||
} catch( Exception ex ) {
|
||||
System.err.println( "Failed to initialize look and feel " + newLookAndFeel.getClass().getName() );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getID() {
|
||||
return getName();
|
||||
|
||||
@@ -24,6 +24,10 @@ package com.formdev.flatlaf;
|
||||
public class FlatLightLaf
|
||||
extends FlatLaf
|
||||
{
|
||||
public static boolean install( ) {
|
||||
return install( new FlatLightLaf() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Flat Light";
|
||||
|
||||
@@ -68,11 +68,7 @@ public class FlatTestFrame
|
||||
ex.printStackTrace();
|
||||
|
||||
// fallback
|
||||
try {
|
||||
UIManager.setLookAndFeel( new FlatLightLaf() );
|
||||
} catch( Exception ex2 ) {
|
||||
ex2.printStackTrace();
|
||||
}
|
||||
FlatLightLaf.install();
|
||||
}
|
||||
|
||||
// create frame
|
||||
|
||||
@@ -46,11 +46,7 @@ public class FlatLafDemo
|
||||
ex.printStackTrace();
|
||||
|
||||
// fallback
|
||||
try {
|
||||
UIManager.setLookAndFeel( new FlatLightLaf() );
|
||||
} catch( Exception ex2 ) {
|
||||
ex2.printStackTrace();
|
||||
}
|
||||
FlatLightLaf.install();
|
||||
}
|
||||
|
||||
// create frame
|
||||
|
||||
Reference in New Issue
Block a user