Package org.apache.jorphan.gui

# Class DynamicStyle

java.lang.Object
org.apache.jorphan.gui.DynamicStyle

@API(since="5.3", status=EXPERIMENTAL) public class DynamicStyle extends Object
By default, Swing does not provide a way to augment components when look and feel changes. There's `JComponent.updateUI()`, however, it requires to sub-class component class.

`DynamicStyle` enables 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
`static Closeable`
`onLaFChange(Runnable action)`
Schedules an action to be executed after each Look and Feel change.
`void`
`updateComponentTreeUI(Component root)`
Updates UI for the components under a given component.
`void`
`updateLaf()`
Re-initializes the current LaF and updates the UI for all the open windows.
`void`
`updateLaf(String className)`
Set new look and feel for all the open windows.
`<T extends JComponent>
T`
`withBorder(T component, String resource)`
`<T extends JComponent>
T`
`withDynamic(T component, Consumer<? super T> onUpdateUi)`
Attaches a configuration action that is executed when Look and Feel changes.
`<T extends JComponent>
T`
`withFont(T component, String resource)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### DynamicStyle

public DynamicStyle()

## Method Details

### withDynamic

@API(since="5.3", status=EXPERIMENTAL) public <T extends JComponent> T withDynamic(T component, Consumer<? super T> onUpdateUi)
Attaches a configuration action that is executed when Look and Feel changes.

Note: the action is executed when `withDynamic` is called, and the action is executed even if the new and the old LaFs are the same.

Type Parameters:
  `T` - type of the component
Parameters:
  `component` - component to update
  `onUpdateUi` - action to run (immediately and when look and feel changes)
Returns:
  input component (e.g. for fluent APIs)

### withBorder

@API(since="5.3", status=EXPERIMENTAL) public <T extends JComponent> T withBorder(T component, String resource)

### withFont

@API(since="5.3", status=EXPERIMENTAL) public <T extends JComponent> T withFont(T component, String resource)

### onLaFChange

@API(since="5.3", status=EXPERIMENTAL) public 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=EXPERIMENTAL) public void updateLaf()
Re-initializes the current LaF and updates the UI for all the open windows.

### updateLaf

@API(since="5.3", status=EXPERIMENTAL) public 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=EXPERIMENTAL) public void updateComponentTreeUI(Component root)
Updates UI for the components under a given component.

Parameters:
  `root` - the root of the hierarchy to update