# LookAndFeelEnhancer

Import: `import com.install4j.api.laf.LookAndFeelEnhancer;`

```java
interface LookAndFeelEnhancer
```

The look and feel enhancer helps screens, form components and styles with specific aspects
of creating the UI.

At runtime the current look and feel enhancer can be obtained
from [`UiUtil.getLookAndFeelEnhancer`](../UiUtil.md#getlookandfeelenhancer).

For developing your own look and feel, see [`LookAndFeelHandler`](LookAndFeelHandler.md).

## Methods

| Signature | Returns | Description |
|---|---|---|
| [`isDark()`](#isdark) | `boolean` | Returns if the look and feel displays a dark mode. |
| [`isDarkModeSwitchingSupported()`](#isdarkmodeswitchingsupported) | `boolean` | Returns if the look and feel supports switching between light and dark mode via [`UiUtil.setDarkUi`](../UiUtil.md#setdarkui-boolean). |
| [`isWideTreeSelection()`](#iswidetreeselection) | `boolean` | Returns if tree selections extend across the entire width of the tree as opposed to just the label. |
| [`isPreventTransparency(JComponent)`](#ispreventtransparency-jcomponent) | `boolean` | Returns if a component should not be made transparent with a call to `JComponent#setOpaque(boolean)` when it is contained in a parent container with a non-default background color. |
| [`createTriStateCheckBox()`](#createtristatecheckbox) | `JCheckBox` | Returns a tri-state checkbox if a specific implementation can be supplied by the look and feel |
| [`getTitleColor()`](#gettitlecolor) | `Color` | Returns the color for the title in alert boxes. |
| [`getAlertFont()`](#getalertfont) | `Font` | Returns the font for normal text in alert boxes. |
| [`getFileChooserLowerAccessoryInset()`](#getfilechooserloweraccessoryinset) | `int` | Some look and feels provide a file chooser dialog where the lower accessory should have an inset on the left side. |
| [`prepareWindow(Window)`](#preparewindow-window) | `void` | Prepare a window before it is displayable. |
| [`disableExtraSelectionPainting(JTree)`](#disableextraselectionpainting-jtree) | `void` | Advises the look and feel UI not to perform any extra drawing for selected nodes in the specified tree. |
| [`getCustomScaleFactor()`](#getcustomscalefactor) | `float` | Returns the custom scale factor for the look and feel. |
| [`computeFontScaleFactor(Font)`](#computefontscalefactor-font) | `float` | Returns the scale factor of a font with respect to the default font. |

### isDark()

```java
default boolean isDark()
```

Returns if the look and feel displays a dark mode.

The default value is `false`.


**See also:**

- [UiUtil.isDarkUi](../UiUtil.md#isdarkui)

### isDarkModeSwitchingSupported()

```java
default boolean isDarkModeSwitchingSupported()
```

Returns if the look and feel supports switching between light and dark mode
via [`UiUtil.setDarkUi`](../UiUtil.md#setdarkui-boolean).

The default value is `false`

### isWideTreeSelection()

```java
default boolean isWideTreeSelection()
```

Returns if tree selections extend across the entire width of the tree as opposed to
just the label.

The default value is `false`.

### isPreventTransparency(JComponent)

```java
default boolean isPreventTransparency(JComponent component)
```

Returns if a component should not be made transparent with a call to
`JComponent#setOpaque(boolean)` when it is contained in a parent container
with a non-default background color.

The default value is `false`.

### createTriStateCheckBox()

```java
default JCheckBox createTriStateCheckBox()
```

Returns a tri-state checkbox if a specific implementation can be supplied by the look and feel

If overridden, it must return an instance that implements
[`IndeterminateStateComponent`](IndeterminateStateComponent.md).
Note that when `JCheckBox#setSelected(boolean)` is called,
the indeterminate state must be set to false.

The default value uses an implementation that permanently activates the armed state for the indeterminate value.

### getTitleColor()

```java
default Color getTitleColor()
```

Returns the color for the title in alert boxes.

The default value is the label foreground color in dark mode and [`LookAndFeelEnhancer.DEFAULT_LIGHT_TITLE_COLOR`](LookAndFeelEnhancer.md#default-light-title-color)
in light mode.

Not applicable on macOS where native alerts are used.

### getAlertFont()

```java
default Font getAlertFont()
```

Returns the font for normal text in alert boxes.

The default value is the label font.

Not applicable on macOS where native alerts are used.

### getFileChooserLowerAccessoryInset()

```java
default int getFileChooserLowerAccessoryInset()
```

Some look and feels provide a file chooser dialog where the lower accessory should
have an inset on the left side.

The default value is `5`.

Not applicable on Windows and macOS where native file chooser dialogs are used.

### prepareWindow(Window)

```java
default void prepareWindow(Window window)
```

Prepare a window before it is displayable. If a custom look and feel sets its own window decoration, it
can make windows undecorated like this:

```
if (window instanceof Frame) {
    ((Frame)window).setUndecorated(true);
} else if (window instanceof Dialog) {
    ((Dialog)window).setUndecorated(true);
}
```

The default implementation is empty.

### disableExtraSelectionPainting(JTree)

```java
default void disableExtraSelectionPainting(JTree tree)
```

Advises the look and feel UI not to perform any extra drawing for selected nodes in the specified tree.
For example, some look and feels paint a wide selection across the entire width of the tree.
This is necessary for trees that handle the painting of the selection themselves.

### getCustomScaleFactor()

```java
default float getCustomScaleFactor()
```

Returns the custom scale factor for the look and feel.
This factor does not include HiDPI scale factors but only an extra scaling of UI element sizes.


**Returns:** the custom scale factor

### computeFontScaleFactor(Font)

```java
default float computeFontScaleFactor(Font font)
```

Returns the scale factor of a font with respect to the default font.
This can be used for sizing UI components correctly.


**Parameters:**

- `font` — the font

**Returns:** the scale factor

## Fields

| Field | Type | Description |
|---|---|---|
| [DEFAULT_LIGHT_TITLE_COLOR](#default-light-title-color) | `Color` | Default color for the title in alert boxes. |

### DEFAULT_LIGHT_TITLE_COLOR

```java
static final Color DEFAULT_LIGHT_TITLE_COLOR
```

Default color for the title in alert boxes. Returned by the default implementation
of [`LookAndFeelEnhancer.getTitleColor`](LookAndFeelEnhancer.md#gettitlecolor) in light mode.

