Class FlatLaf

    • 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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • FlatLaf

        public FlatLaf()
    • 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 class javax.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 if JFrame.isDefaultLookAndFeelDecorated() or JDialog.isDefaultLookAndFeelDecorated() return true.

        Overrides:
        getSupportsWindowDecorations in class javax.swing.LookAndFeel
      • isNativeLookAndFeel

        public boolean isNativeLookAndFeel()
        Specified by:
        isNativeLookAndFeel in class javax.swing.LookAndFeel
      • isSupportedLookAndFeel

        public boolean isSupportedLookAndFeel()
        Specified by:
        isSupportedLookAndFeel in class javax.swing.LookAndFeel
      • getDisabledIcon

        public javax.swing.Icon getDisabledIcon​(javax.swing.JComponent component,
                                                javax.swing.Icon icon)
        Overrides:
        getDisabledIcon in class javax.swing.LookAndFeel
      • initialize

        public void initialize()
        Overrides:
        initialize in class javax.swing.plaf.basic.BasicLookAndFeel
      • uninitialize

        public void uninitialize()
        Overrides:
        uninitialize in class javax.swing.plaf.basic.BasicLookAndFeel
      • getDefaults

        public javax.swing.UIDefaults getDefaults()
        Overrides:
        getDefaults in class javax.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 ); after UIManager.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 class FlatLightLaf or FlatDarkLaf.properties for class FlatDarkLaf. 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, or null
      • 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()