# Style

Import: `import com.install4j.api.styles.Style;`

```java
interface Style extends VisualContainerBean, StyleContextReceiver, ControlButtonContainer
```

All styles must implement this interface. You have to override all methods and provide a public constructor with no arguments.
It is recommended that you choose [`AbstractStyle`](AbstractStyle.md) as a superclass.

Styles are configurable in the install4j GUI on the "Installer->Styles" step.
The life-cycle of screen style instances is controlled by the framework. Styles are only instantiated
once and their [`Style.createComponent`](Style.md#createcomponent) method is called for each screen that the screen style is used for.

If you nest styles, implement [`NestedStyleContainer`](NestedStyleContainer.md) as well.

## Inherited from

- [VisualContainerBean](../beans/VisualContainerBean.md) — 3 methods
- [StyleContextReceiver](StyleContextReceiver.md) — 1 methods
- [ControlButtonContainer](ControlButtonContainer.md) — 4 methods

## Methods

| Signature | Returns | Description |
|---|---|---|
| [`setContext(Context)`](#setcontext-context) | `void` | This method is called by the framework to set the `Context` just after the screen style has been constructed. |
| [`createComponent()`](#createcomponent) | `JComponent` | Create the UI component for the style. |
| [`isStandalone()`](#isstandalone) | `boolean` | Returns if the screen style is intended to be applied to installer applications, screens and screen groups. |
| [`willActivate()`](#willactivate) | `void` | This method is called by the framework just before a screen with this screen style is activated. |
| [`activated()`](#activated) | `void` | This method is called by the framework just after a screen with this screen style has been activated. |
| [`deactivated()`](#deactivated) | `void` | This method is called by the framework just after a screen with this screen style has been deactivated. |

### setContext(Context)

```java
void setContext(Context context)
```

This method is called by the framework to set the `Context` just after the
screen style has been constructed. This is either an `InstallerContext` or an
`UninstallerContext`, depending on whether the screen style is used in an
installer or an uninstaller.

When nesting other styles, this is the earliest occasion that the screen style manager can be obtained by calling
`context.getWizardContext().getStyleManager()`.


**Parameters:**

- `context` — the context.

### createComponent()

```java
JComponent createComponent()
```

Create the UI component for the style. Depending on the return value of the [`Style.isFillHorizontal`](Style.md#isfillhorizontal) and the
[`Style.isFillVertical`](Style.md#isfillvertical) methods, the component grows to fill all available horizontal or vertical space.
The method must not return `null`.

Never call this method yourself. For nested styles, call [`StyleManager.createStyleComponent`](StyleManager.md#createstylecomponent-style)
instead.

Each screen style is only instantiated once, and this method is called multiple times for each screen that uses
the style. In console or unattended mode, this method is never called.


**Returns:** the UI component

**See also:**

- [Style.isFillHorizontal](Style.md#isfillhorizontal)
- [Style.isFillVertical](Style.md#isfillvertical)
- [NestedStyleContainer](NestedStyleContainer.md)

### isStandalone()

```java
boolean isStandalone()
```

Returns if the screen style is intended to be applied to installer applications, screens and screen groups.
Only standalone styles are available in the corresponding screen style selectors and can be set as the default style.
If this method returns `false`, the screen style can only be nested into other styles.


**Returns:** `true` or `false`

### willActivate()

```java
void willActivate()
```

This method is called by the framework just before a screen with this screen style is activated.
This call has to be delegated to nested styles by using [`StyleManager.willActivate`](StyleManager.md#willactivate-style).


**See also:**

- [Screen.willActivate](../screens/Screen.md#willactivate)

### activated()

```java
void activated()
```

This method is called by the framework just after a screen with this screen style has been activated.
This call has to be delegated to nested styles by using [`StyleManager.activated`](StyleManager.md#activated-style)


**See also:**

- [Screen.activated](../screens/Screen.md#activated)

### deactivated()

```java
void deactivated()
```

This method is called by the framework just after a screen with this screen style has been deactivated.
This call has to be delegated to nested styles by using [`StyleManager.deactivated`](StyleManager.md#deactivated-style)

