Class DynamicStyle
-
- All Implemented Interfaces:
@API(since = "5.3", status = API.Status.EXPERIMENTAL) public class DynamicStyleBy default, Swing does not provide a way to augment components when look and feel changes. There's updateUI, however, it requires to sub-class component class.
DynamicStyleenables to augment the components (e.g. border, font, color) as LaF changes
-
-
Constructor Summary
Constructors Constructor Description DynamicStyle()
-
Method Summary
Modifier and Type Method Description <T extends JComponent> TwithDynamic(T component, Consumer<in T> onUpdateUi)Attaches a configuration action that is executed when Look and Feel changes. <T extends JComponent> TwithBorder(T component, String resource)<T extends JComponent> TwithFont(T component, String resource)static CloseableonLaFChange(Runnable action)Schedules an action to be executed after each Look and Feel change. voidupdateLaf()Re-initializes the current LaF and updates the UI for all the open windows. voidupdateLaf(String className)Set new look and feel for all the open windows. voidupdateComponentTreeUI(Component root)Updates UI for the components under a given component. -
-
Method Detail
-
withDynamic
@API(since = "5.3", status = API.Status.EXPERIMENTAL) <T extends JComponent> T withDynamic(T component, Consumer<in T> onUpdateUi)
Attaches a configuration action that is executed when Look and Feel changes.
Note: the action is executed when
withDynamicis called, and the action is executed even if the new and the old LaFs are the same.- Parameters:
component- component to updateonUpdateUi- action to run (immediately and when look and feel changes)- Returns:
input component (e.g. for fluent APIs)
-
withBorder
@API(since = "5.3", status = API.Status.EXPERIMENTAL) <T extends JComponent> T withBorder(T component, String resource)
-
withFont
@API(since = "5.3", status = API.Status.EXPERIMENTAL) <T extends JComponent> T withFont(T component, String resource)
-
onLaFChange
@API(since = "5.3", status = API.Status.EXPERIMENTAL) static Closeable onLaFChange(Runnable action)
Schedules an action to be executed after each Look and Feel change.
- Parameters:
action- action to execute- Returns:
a handle that can be used to un-register the listener
-
updateLaf
@API(since = "5.3", status = API.Status.EXPERIMENTAL) void updateLaf()
Re-initializes the current LaF and updates the UI for all the open windows.
-
updateLaf
@API(since = "5.3", status = API.Status.EXPERIMENTAL) void updateLaf(String className)
Set new look and feel for all the open windows.
- Parameters:
className- look and feel class name
-
updateComponentTreeUI
@API(since = "5.3", status = API.Status.EXPERIMENTAL) void updateComponentTreeUI(Component root)
Updates UI for the components under a given component.
- Parameters:
root- the root of the hierarchy to update
-
-
-
-