# AbstractFormComponent

Import: `import com.install4j.api.formcomponents.AbstractFormComponent;`

```java
public abstract class AbstractFormComponent extends AbstractBean implements FormComponent, FormEnvironmentContainer
```

Abstract base class for form components.
All methods that have a reasonable default answer are overridden in the class.
This class saves the context and the form environment that are set by the framework and provides getters for them.
In addition, the "enabled" and "visible" properties are handled by invoking the corresponding setters on all
components in the `ComponentTuple` of the form component.

## Inherited from

- [AbstractBean](../beans/AbstractBean.md) — 22 methods
- [FormComponent](FormComponent.md) — 23 methods

## Methods

| Signature | Returns | Description |
|---|---|---|
| [`getTextWithoutMnemonics(String)`](#gettextwithoutmnemonics-string) | `String` |  |
| [`getMnemonicCharIndex(String)`](#getmnemoniccharindex-string) | `int` |  |
| [`setContext(Context)`](#setcontext-context) | `void` |  |
| [`getContext()`](#getcontext) | `Context` | Returns the `Context` that the framework has associated with this form component in `setContext`. |
| [`setFormEnvironment(FormEnvironment)`](#setformenvironment-formenvironment) | `void` |  |
| [`getFormEnvironment()`](#getformenvironment) | `FormEnvironment` | Returns the `FormEnvironment` that the framework has associated with this form component in `setFormEnvironment`. |
| [`isEnabled()`](#isenabled) | `boolean` |  |
| [`setEnabled(boolean)`](#setenabled-boolean) | `void` |  |
| [`setVisible(boolean)`](#setvisible-boolean) | `void` |  |
| [`isVisible()`](#isvisible) | `boolean` |  |
| [`migrateIds(Map<String, String>)`](#migrateids-map-string-string) | `void` |  |
| [`requestFocus()`](#requestfocus) | `void` |  |
| [`hasUserInput()`](#hasuserinput) | `boolean` |  |
| [`createLeftComponent()`](#createleftcomponent) | `JComponent` |  |
| [`isFillCenterVertical()`](#isfillcentervertical) | `boolean` |  |
| [`createRightComponent()`](#createrightcomponent) | `JComponent` |  |
| [`getConfigurationObject()`](#getconfigurationobject) | `Object` |  |
| [`getConfigurationObjectClass()`](#getconfigurationobjectclass) | `Class<?>` |  |
| [`checkCompleted()`](#checkcompleted) | `boolean` |  |
| [`initialize()`](#initialize) | `void` |  |
| [`protected initalize()`](#protected-initalize) | `void` | The name of this method has changed to "initialize" |
| [`formWillActivate()`](#formwillactivate) | `void` |  |
| [`formActivated()`](#formactivated) | `void` |  |
| [`formDeactivated()`](#formdeactivated) | `void` |  |
| [`handleConsole(Console)`](#handleconsole-console) | `boolean` |  |
| [`handleUnattended()`](#handleunattended) | `boolean` |  |
| [`protected getInitValue(Object, String, Class<?>)`](#protected-getinitvalue-object-string-class) | `Object` | Helper method to get an init value. |
| [`replaceFormVariables(String)`](#replaceformvariables-string) | `String` | Same as [`AbstractBean.replaceVariables`](../beans/AbstractBean.md#replacevariables-string), only with the additional replacement of form variables. |
| [`replaceFormVariables(String, ReplacementMode)`](#replaceformvariables-string-replacementmode) | `String` | Same as [`AbstractBean.replaceVariables`](../beans/AbstractBean.md#replacevariables-string-replacementmode), only with the additional replacement of form variables. |
| [`replaceFormVariables(String, VariableErrorHandlingDescriptor)`](#replaceformvariables-string-variableerrorhandlingdescriptor) | `String` | Same as [`AbstractBean.replaceVariables`](../beans/AbstractBean.md#replacevariables-string-variableerrorhandlingdescriptor), only with the additional replacement of form variables. |
| [`replaceFormVariables(String, ReplacementMode, VariableErrorHandlingDescriptor)`](#replaceformvariables-string-replacementmode-variableerrorhandlingdescriptor) | `String` | Same as [`AbstractBean.replaceVariables`](../beans/AbstractBean.md#replacevariables-string-replacementmode-variableerrorhandlingdescriptor), only with the additional replacement of form variables. |
| [`replaceFormVariables(String[])`](#replaceformvariables-string) | `String[]` | Same as [`AbstractBean.replaceVariables`](../beans/AbstractBean.md#replacevariables-string), only with the additional replacement of form variables. |
| [`replaceFormVariables(String[], VariableErrorHandlingDescriptor)`](#replaceformvariables-string-variableerrorhandlingdescriptor) | `String[]` | Same as [`AbstractBean.replaceVariables`](../beans/AbstractBean.md#replacevariables-string-variableerrorhandlingdescriptor), only with the additional replacement of form variables. |

### getTextWithoutMnemonics(String)

```java
public static String getTextWithoutMnemonics(String text)
```

### getMnemonicCharIndex(String)

```java
public static int getMnemonicCharIndex(String text)
```

### setContext(Context)

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

### getContext()

```java
public Context getContext()
```

Returns the `Context` that the framework has associated with
this form component in `setContext`.


**Returns:** the installer context.

### setFormEnvironment(FormEnvironment)

```java
public void setFormEnvironment(FormEnvironment formEnvironment)
```

### getFormEnvironment()

```java
public FormEnvironment getFormEnvironment()
```

Returns the `FormEnvironment` that the framework has associated with
this form component in `setFormEnvironment`.


**Returns:** the installer context.

### isEnabled()

```java
public boolean isEnabled()
```

### setEnabled(boolean)

```java
public void setEnabled(boolean enabled)
```

### setVisible(boolean)

```java
public void setVisible(boolean visible)
```

### isVisible()

```java
public boolean isVisible()
```

### migrateIds(Map<String, String>)

```java
public void migrateIds(Map<String, String> oldIdToNewId)
```

### requestFocus()

```java
public void requestFocus()
```

### hasUserInput()

```java
public boolean hasUserInput()
```

### createLeftComponent()

```java
public JComponent createLeftComponent()
```

### isFillCenterVertical()

```java
public boolean isFillCenterVertical()
```

### createRightComponent()

```java
public JComponent createRightComponent()
```

### getConfigurationObject()

```java
public Object getConfigurationObject()
```

### getConfigurationObjectClass()

```java
public Class<?> getConfigurationObjectClass()
```

### checkCompleted()

```java
public boolean checkCompleted()
```

### initialize()

```java
public void initialize()
```

### protected initalize()

```java
@Deprecated protected final void initalize()
```

> **⚠ Deprecated.**

The name of this method has changed to "initialize"

### formWillActivate()

```java
public void formWillActivate()
```

### formActivated()

```java
public void formActivated()
```

### formDeactivated()

```java
public void formDeactivated()
```

### handleConsole(Console)

```java
public boolean handleConsole(Console console) throws UserCanceledException
```

### handleUnattended()

```java
public boolean handleUnattended()
```

### protected getInitValue(Object, String, Class<?>)

```java
protected Object getInitValue(Object defaultValue, String variableName, Class<?> valueClass)
```

Helper method to get an init value. If the variable is defined and of class valueClass, the
variable value is used. Otherwise, the default value is used.

This method offers special handling for boolean, integer and enum values where a string value
will be parsed as well. In the case of boolean values, "true" and "false" in any case are
accepted as valid values. In the case of enum values, the enum constant name is accepted as
a string value.


**Parameters:**

- `defaultValue` — the default value. Can be null.
- `variableName` — the installer variable name the value will be assigned to later on
- `valueClass` — the desired class of the variable content

**Returns:** the init value to be used

### replaceFormVariables(String)

```java
public String replaceFormVariables(String value) throws UndefinedVariableException
```

Same as [`AbstractBean.replaceVariables`](../beans/AbstractBean.md#replacevariables-string), only with the additional replacement of form variables.


**See also:**

- [FormEnvironment.replaceFormVariables](FormEnvironment.md#replaceformvariables-string-replacementmode-variableerrorhandlingdescriptor)

### replaceFormVariables(String, ReplacementMode)

```java
public String replaceFormVariables(String value, ReplacementMode replacementMode) throws UndefinedVariableException
```

Same as [`AbstractBean.replaceVariables`](../beans/AbstractBean.md#replacevariables-string-replacementmode), only with the additional replacement of form variables.


**See also:**

- [FormEnvironment.replaceFormVariables](FormEnvironment.md#replaceformvariables-string-replacementmode-variableerrorhandlingdescriptor)

### replaceFormVariables(String, VariableErrorHandlingDescriptor)

```java
public String replaceFormVariables(String value, VariableErrorHandlingDescriptor errorHandlingDescriptor) throws UndefinedVariableException
```

Same as [`AbstractBean.replaceVariables`](../beans/AbstractBean.md#replacevariables-string-variableerrorhandlingdescriptor), only with the additional replacement of form variables.


**See also:**

- [FormEnvironment.replaceFormVariables](FormEnvironment.md#replaceformvariables-string-replacementmode-variableerrorhandlingdescriptor)

### replaceFormVariables(String, ReplacementMode, VariableErrorHandlingDescriptor)

```java
public String replaceFormVariables(String value, ReplacementMode replacementMode, VariableErrorHandlingDescriptor errorHandlingDescriptor) throws UndefinedVariableException
```

Same as [`AbstractBean.replaceVariables`](../beans/AbstractBean.md#replacevariables-string-replacementmode-variableerrorhandlingdescriptor), only with the additional replacement of form variables.


**See also:**

- [FormEnvironment.replaceFormVariables](FormEnvironment.md#replaceformvariables-string-replacementmode-variableerrorhandlingdescriptor)

### replaceFormVariables(String[])

```java
public String[] replaceFormVariables(String[] values) throws UndefinedVariableException
```

Same as [`AbstractBean.replaceVariables`](../beans/AbstractBean.md#replacevariables-string), only with the additional replacement of form variables.


**See also:**

- [FormEnvironment.replaceFormVariables](FormEnvironment.md#replaceformvariables-string-replacementmode-variableerrorhandlingdescriptor)

### replaceFormVariables(String[], VariableErrorHandlingDescriptor)

```java
public String[] replaceFormVariables(String[] values, VariableErrorHandlingDescriptor errorHandlingDescriptor) throws UndefinedVariableException
```

Same as [`AbstractBean.replaceVariables`](../beans/AbstractBean.md#replacevariables-string-variableerrorhandlingdescriptor), only with the additional replacement of form variables.


**See also:**

- [FormEnvironment.replaceFormVariables](FormEnvironment.md#replaceformvariables-string-replacementmode-variableerrorhandlingdescriptor)

## Constructors

| Signature | Description |
|---|---|
| [`AbstractFormComponent()`](#abstractformcomponent) |  |

### AbstractFormComponent()

```java
public AbstractFormComponent()
```

## Fields

| Field | Type | Description |
|---|---|---|
| [MNEMONIC_PATTERN](#mnemonic-pattern) | `Pattern` |  |

### MNEMONIC_PATTERN

```java
public static final Pattern MNEMONIC_PATTERN
```

