Class FlatLaf
- java.lang.Object
-
- javax.swing.LookAndFeel
-
- javax.swing.plaf.basic.BasicLookAndFeel
-
- com.formdev.flatlaf.FlatLaf
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
FlatDarkLaf
,FlatLightLaf
,FlatPropertiesLaf
,IntelliJTheme.ThemeLaf
public abstract class FlatLaf extends javax.swing.plaf.basic.BasicLookAndFeel
The base class for all Flat LaFs.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description FlatLaf()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected java.util.Properties
getAdditionalDefaults()
javax.swing.UIDefaults
getDefaults()
javax.swing.Icon
getDisabledIcon(javax.swing.JComponent component, javax.swing.Icon icon)
java.lang.String
getID()
Returns the look and feel identifier.protected java.util.List<java.lang.Class<?>>
getLafClassesForDefaultsLoading()
boolean
getSupportsWindowDecorations()
Returns whether FlatLaf supports custom window decorations.static void
hideMnemonics()
void
initialize()
static void
initIconColors(javax.swing.UIDefaults defaults, boolean dark)
Adds the default color palette for action icons and object icons to the given UIDefaults.static boolean
install(javax.swing.LookAndFeel newLookAndFeel)
abstract boolean
isDark()
static boolean
isLafDark()
Checks whether the current look and feel is dark.boolean
isNativeLookAndFeel()
static boolean
isShowMnemonics()
boolean
isSupportedLookAndFeel()
static void
registerCustomDefaultsSource(java.io.File folder)
Registers a folder where FlatLaf searches for properties files with custom UI defaults.static void
registerCustomDefaultsSource(java.lang.String packageName)
Registers a package where FlatLaf searches for properties files with custom UI defaults.static void
registerCustomDefaultsSource(java.lang.String packageName, java.lang.ClassLoader classLoader)
Registers a package where FlatLaf searches for properties files with custom UI defaults.static void
showMnemonics(java.awt.Component c)
void
uninitialize()
static void
unregisterCustomDefaultsSource(java.io.File folder)
static void
unregisterCustomDefaultsSource(java.lang.String packageName)
static void
unregisterCustomDefaultsSource(java.lang.String packageName, java.lang.ClassLoader classLoader)
static void
updateUI()
Update UI of all application windows immediately.static void
updateUILater()
Update UI of all application windows later.-
Methods inherited from class javax.swing.plaf.basic.BasicLookAndFeel
createAudioAction, getAudioActionMap, initClassDefaults, initComponentDefaults, initSystemColorDefaults, loadSystemColors, playSound
-
Methods inherited from class javax.swing.LookAndFeel
getDescription, getDesktopPropertyValue, getDisabledSelectedIcon, getLayoutStyle, getName, installBorder, installColors, installColorsAndFont, installProperty, loadKeyBindings, makeComponentInputMap, makeIcon, makeInputMap, makeKeyBindings, provideErrorFeedback, toString, uninstallBorder
-
-
-
-
Method Detail
-
install
public static boolean install(javax.swing.LookAndFeel newLookAndFeel)
-
getID
public java.lang.String getID()
Returns the look and feel identifier.Syntax: "FlatLaf - ${theme-name}"
Use
UIManager.getLookAndFeel().getID().startsWith( "FlatLaf" )
to check whether the current look and feel is FlatLaf.- Specified by:
getID
in classjavax.swing.LookAndFeel
-
isDark
public abstract boolean isDark()
-
isLafDark
public static boolean isLafDark()
Checks whether the current look and feel is dark.
-
getSupportsWindowDecorations
public boolean getSupportsWindowDecorations()
Returns whether FlatLaf supports custom window decorations. This depends on the operating system and on the used Java runtime.To use custom window decorations in your application, enable them with following code (before creating any frames or dialogs). Then custom window decorations are only enabled if this method returns
true
.JFrame.setDefaultLookAndFeelDecorated( true ); JDialog.setDefaultLookAndFeelDecorated( true );
Returns
true
on Windows 10,false
otherwise.Return also
false
if running on Windows 10 in JetBrains Runtime 11 (or later) (source code on github) and JBR supports custom window decorations. In this case, JBR custom decorations are enabled ifJFrame.isDefaultLookAndFeelDecorated()
orJDialog.isDefaultLookAndFeelDecorated()
returntrue
.- Overrides:
getSupportsWindowDecorations
in classjavax.swing.LookAndFeel
-
isNativeLookAndFeel
public boolean isNativeLookAndFeel()
- Specified by:
isNativeLookAndFeel
in classjavax.swing.LookAndFeel
-
isSupportedLookAndFeel
public boolean isSupportedLookAndFeel()
- Specified by:
isSupportedLookAndFeel
in classjavax.swing.LookAndFeel
-
getDisabledIcon
public javax.swing.Icon getDisabledIcon(javax.swing.JComponent component, javax.swing.Icon icon)
- Overrides:
getDisabledIcon
in classjavax.swing.LookAndFeel
-
initialize
public void initialize()
- Overrides:
initialize
in classjavax.swing.plaf.basic.BasicLookAndFeel
-
uninitialize
public void uninitialize()
- Overrides:
uninitialize
in classjavax.swing.plaf.basic.BasicLookAndFeel
-
getDefaults
public javax.swing.UIDefaults getDefaults()
- Overrides:
getDefaults
in classjavax.swing.plaf.basic.BasicLookAndFeel
-
getLafClassesForDefaultsLoading
protected java.util.List<java.lang.Class<?>> getLafClassesForDefaultsLoading()
-
getAdditionalDefaults
protected java.util.Properties getAdditionalDefaults()
-
initIconColors
public static void initIconColors(javax.swing.UIDefaults defaults, boolean dark)
Adds the default color palette for action icons and object icons to the given UIDefaults.This method is public and static to allow using the color palette with other LaFs (e.g. Windows LaF). To do so invoke:
FlatLaf.initIconColors( UIManager.getLookAndFeelDefaults(), false );
afterUIManager.setLookAndFeel( ... );
.The colors are based on IntelliJ Platform Action icons and Noun icons
These colors may be changed by IntelliJ Platform themes.
-
registerCustomDefaultsSource
public static void registerCustomDefaultsSource(java.lang.String packageName)
Registers a package where FlatLaf searches for properties files with custom UI defaults.This can be used to specify application specific UI defaults that override UI values of existing themes or to define own UI values used in custom controls.
There may be multiple properties files in that package for multiple themes. The properties file name must match the used theme class names. E.g.
FlatLightLaf.properties
for classFlatLightLaf
orFlatDarkLaf.properties
for classFlatDarkLaf
.FlatLaf.properties
is loaded first for all themes.These properties files are loaded after theme and addon properties files and can therefore override all UI defaults.
Invoke this method before setting the look and feel.
- Parameters:
packageName
- a package name (e.g. "com.myapp.resources")
-
unregisterCustomDefaultsSource
public static void unregisterCustomDefaultsSource(java.lang.String packageName)
-
registerCustomDefaultsSource
public static void registerCustomDefaultsSource(java.lang.String packageName, java.lang.ClassLoader classLoader)
Registers a package where FlatLaf searches for properties files with custom UI defaults.See
registerCustomDefaultsSource(String)
for details.- Parameters:
packageName
- a package name (e.g. "com.myapp.resources")classLoader
- a class loader used to find resources, ornull
-
unregisterCustomDefaultsSource
public static void unregisterCustomDefaultsSource(java.lang.String packageName, java.lang.ClassLoader classLoader)
-
registerCustomDefaultsSource
public static void registerCustomDefaultsSource(java.io.File folder)
Registers a folder where FlatLaf searches for properties files with custom UI defaults.See
registerCustomDefaultsSource(String)
for details.- Parameters:
folder
- a folder
-
unregisterCustomDefaultsSource
public static void unregisterCustomDefaultsSource(java.io.File folder)
-
updateUI
public static void updateUI()
Update UI of all application windows immediately. Invoke after changing LaF.
-
updateUILater
public static void updateUILater()
Update UI of all application windows later.
-
isShowMnemonics
public static boolean isShowMnemonics()
-
showMnemonics
public static void showMnemonics(java.awt.Component c)
-
hideMnemonics
public static void hideMnemonics()
-
-