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.BasicLookAndFeelThe base class for all Flat LaFs.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceFlatLaf.DisabledIconProviderA provider for disabled icons.
-
Constructor Summary
Constructors Constructor Description FlatLaf()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)protected java.util.PropertiesgetAdditionalDefaults()javax.swing.UIDefaultsgetDefaults()javax.swing.IcongetDisabledIcon(javax.swing.JComponent component, javax.swing.Icon icon)java.lang.StringgetID()Returns the look and feel identifier.protected java.util.List<java.lang.Class<?>>getLafClassesForDefaultsLoading()booleangetSupportsWindowDecorations()Returns whether FlatLaf supports custom window decorations.inthashCode()static voidhideMnemonics()voidinitialize()static voidinitIconColors(javax.swing.UIDefaults defaults, boolean dark)Adds the default color palette for action icons and object icons to the given UIDefaults.static booleaninstall(javax.swing.LookAndFeel newLookAndFeel)Sets the application look and feel to the given LaF usingUIManager.setLookAndFeel(javax.swing.LookAndFeel).static voidinstallLafInfo(java.lang.String lafName, java.lang.Class<? extends javax.swing.LookAndFeel> lafClass)Adds the given look and feel to the set of available look and feels.abstract booleanisDark()static booleanisLafDark()Checks whether the current look and feel is dark.booleanisNativeLookAndFeel()static booleanisShowMnemonics()booleanisSupportedLookAndFeel()static voidregisterCustomDefaultsSource(java.io.File folder)Registers a folder where FlatLaf searches for properties files with custom UI defaults.static voidregisterCustomDefaultsSource(java.lang.String packageName)Registers a package where FlatLaf searches for properties files with custom UI defaults.static voidregisterCustomDefaultsSource(java.lang.String packageName, java.lang.ClassLoader classLoader)Registers a package where FlatLaf searches for properties files with custom UI defaults.static voidshowMnemonics(java.awt.Component c)voiduninitialize()static voidunregisterCustomDefaultsSource(java.io.File folder)static voidunregisterCustomDefaultsSource(java.lang.String packageName)static voidunregisterCustomDefaultsSource(java.lang.String packageName, java.lang.ClassLoader classLoader)static voidupdateUI()Update UI of all application windows immediately.static voidupdateUILater()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)
Sets the application look and feel to the given LaF usingUIManager.setLookAndFeel(javax.swing.LookAndFeel).
-
installLafInfo
public static void installLafInfo(java.lang.String lafName, java.lang.Class<? extends javax.swing.LookAndFeel> lafClass)Adds the given look and feel to the set of available look and feels.Useful if your application uses
UIManager.getInstalledLookAndFeels()to query available LaFs and display them to the user in a combobox.
-
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:
getIDin 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
trueon Windows 10,falseotherwise.Return also
falseif 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:
getSupportsWindowDecorationsin classjavax.swing.LookAndFeel
-
isNativeLookAndFeel
public boolean isNativeLookAndFeel()
- Specified by:
isNativeLookAndFeelin classjavax.swing.LookAndFeel
-
isSupportedLookAndFeel
public boolean isSupportedLookAndFeel()
- Specified by:
isSupportedLookAndFeelin classjavax.swing.LookAndFeel
-
getDisabledIcon
public javax.swing.Icon getDisabledIcon(javax.swing.JComponent component, javax.swing.Icon icon)- Overrides:
getDisabledIconin classjavax.swing.LookAndFeel
-
initialize
public void initialize()
- Overrides:
initializein classjavax.swing.plaf.basic.BasicLookAndFeel
-
uninitialize
public void uninitialize()
- Overrides:
uninitializein classjavax.swing.plaf.basic.BasicLookAndFeel
-
getDefaults
public javax.swing.UIDefaults getDefaults()
- Overrides:
getDefaultsin 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.propertiesfor classFlatLightLaforFlatDarkLaf.propertiesfor classFlatDarkLaf.FlatLaf.propertiesis 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()
-
equals
public final boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public final int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-