Package ca.corbett.extras
Class LookAndFeelManager
java.lang.Object
ca.corbett.extras.LookAndFeelManager
This is a simple wrapper class to manage the various look and feels that
spring-extras supports.
- Since:
- 2025-04-22
- Author:
- scorbo2
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddChangeListener(ChangeListener listener) If you wish to be informed when the current Look and Feel changes, because you have perhaps set some custom colors across your UI, you can subscribe to receive notification when it happens.static ColorgetLafColor(String key, Color defaultColor) Returns the Color for the specified key, or returns the defaultColor if the specified key returns nothing.static voidCan be invoked (ideally at application startup before any GUI elements are shown) to install all the "extra" LaFs that swing-extras supports, namely from the FlatLaf package and also JTattoo.static voidremoveChangeListener(ChangeListener listener) static voidGiven a class name for a LookAndFeel class, switch the current LaF to that one.static voidInvoke to switch the current LaF to the specified one (you can either get the LookAndFeelInfo from a LookAndFeelProperty via user input or you can specify it yourself).
-
Constructor Details
-
LookAndFeelManager
public LookAndFeelManager()
-
-
Method Details
-
installExtraLafs
public static void installExtraLafs()Can be invoked (ideally at application startup before any GUI elements are shown) to install all the "extra" LaFs that swing-extras supports, namely from the FlatLaf package and also JTattoo. With the JTattoo themes we have to tweak them a bit to avoid some wonky default behaviour with menus (it wants to show a sideways logo in every menu for some reason - we can disable it).Implementation note: this code is in a public static method instead of in a static initializer block because your app might not care about LaF, in which case you can just ignore this method and avoid whatever memory penalty in would otherwise incur.
-
switchLaf
Invoke to switch the current LaF to the specified one (you can either get the LookAndFeelInfo from a LookAndFeelProperty via user input or you can specify it yourself). -
switchLaf
Given a class name for a LookAndFeel class, switch the current LaF to that one. We make no check here to ensure that the given class actually exists.- Parameters:
className- The name of the LaF class in question.
-
getLafColor
Returns the Color for the specified key, or returns the defaultColor if the specified key returns nothing. -
addChangeListener
If you wish to be informed when the current Look and Feel changes, because you have perhaps set some custom colors across your UI, you can subscribe to receive notification when it happens.Note: you'll only receive a ChangeEvent if the Look and Feel was switched via this class. If your code talks to UIManager directly, then this class is cut out of the loop and the ChangeEvent will not fire.
- Parameters:
listener- A ChangeListener to receive a change event when LaF changes.
-
removeChangeListener
-