Top Description Inners Fields Constructors Methods
com.dlsc.gemsfx

public Class LimitedTextArea

extends ResizableTextArea
Class Inheritance
Imports
com.dlsc.gemsfx.skins.LimitedTextAreaSkin, com.dlsc.gemsfx.util.IntegerRange, javafx.beans.property.BooleanProperty, .DoubleProperty, .ObjectProperty, .ReadOnlyBooleanProperty, .ReadOnlyBooleanWrapper, .SimpleDoubleProperty, .SimpleObjectProperty, .SimpleStringProperty, .StringProperty, javafx.collections.FXCollections, .ObservableList, javafx.css.CssMetaData, .Styleable, .StyleableBooleanProperty, .StyleableProperty, javafx.css.converter.BooleanConverter, javafx.scene.control.Skin, java.util.ArrayList, .Collections, .List, .Objects

A specialized text area view that imposes restrictions on the input text length, allowing specification of minimum and maximum character limits. It provides the functionality to define a range of allowed text lengths and supports the removal of specified strings by replacing them with an empty string. This component is designed for scenarios where input text needs to adhere to specific length requirements and certain substrings are not permitted.

If the text length range is not specified, the value of the text length indicator label will reflect the number of characters in the text area. If a range is specified, the label will show the difference between the current text length and the maximum allowed character count. Should the text exceed the allowed maximum, the label will display a negative number.

Use cases include form fields where input character count is restricted within a certain range for validation purposes, or text areas that need to filter out specific unwanted characters or phrases.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
private static class

Field Summary

Modifier and TypeField and Description
private final ObjectProperty<IntegerRange>
private static final boolean
private static final String
private final ObservableList<String>
excludedItems

A list of items that should be excluded from the text content.

private final ObjectProperty<LimitedTextArea.LengthDisplayMode>
private final ReadOnlyBooleanWrapper
private BooleanProperty
private final StringProperty
private final DoubleProperty

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
public final ObjectProperty<IntegerRange>

Returns:

the character range limit property
characterRangeLimitProperty
()

The character range limit property defines the minimum and maximum number of characters allowed in the text area.

protected Skin<?>
createDefaultSkin()

Overrides com.dlsc.gemsfx.ResizableTextArea.createDefaultSkin.

Create a new instance of the default skin for this control.

public final IntegerRange
public static List<CssMetaData<? extends Styleable, ?>>
getClassCssMetaData()

Hides javafx.scene.control.TextArea.getClassCssMetaData.

Gets the CssMetaData associated with this class, which may include the CssMetaData of its superclasses.

public List<CssMetaData<? extends Styleable, ?>>
getControlCssMetaData()

Overrides javafx.scene.control.TextArea.getControlCssMetaData.

Gets the unmodifiable list of the control's CSS-styleable properties.

public final ObservableList<String>
public final LimitedTextArea.LengthDisplayMode
public final String
public String
getUserAgentStylesheet()

Overrides com.dlsc.gemsfx.ResizableTextArea.getUserAgentStylesheet.

An implementation may specify its own user-agent styles for this Region, and its children, by overriding this method.

public final double
public final double
public final boolean
public final boolean
public final ObjectProperty<LimitedTextArea.LengthDisplayMode>

Returns:

the length display mode property
lengthDisplayModeProperty
()

The length display mode property defines when the text length indicator label should be displayed.

public final ReadOnlyBooleanProperty
outOfRangeProperty()

A read-only property indicating whether the text content is over the maximum length or under the minimum length.

public final void
setCharacterRangeLimit(IntegerRange characterRangeLimit)

public final void
private final void
setOutOfRange(boolean outOfRange)

public final void
setShowBottom(boolean showBottom)

public final void
public final void
setWarningThreshold(double warningThreshold)

public final BooleanProperty
public final StringProperty
tipsProperty()

The tips property used to display a hint or description of the text area.

public final DoubleProperty
warningThresholdProperty()

The warning threshold is a value between 0 and 1.

Inherited from com.dlsc.gemsfx.ResizableTextArea:
isResizeHorizontalisResizeVerticalresizeHorizontalPropertyresizeVerticalPropertysetResizeHorizontalsetResizeVertical

Field Detail

characterRangeLimitback to summary
private final ObjectProperty<IntegerRange> characterRangeLimit
DEFAULT_SHOW_BOTTOMback to summary
private static final boolean DEFAULT_SHOW_BOTTOM
DEFAULT_STYLE_CLASSback to summary
private static final String DEFAULT_STYLE_CLASS
excludedItemsback to summary
private final ObservableList<String> excludedItems

A list of items that should be excluded from the text content. e.g. "\r", "\n", "\t" ,"." etc.

lengthDisplayModeback to summary
private final ObjectProperty<LimitedTextArea.LengthDisplayMode> lengthDisplayMode
outOfRangeback to summary
private final ReadOnlyBooleanWrapper outOfRange
showBottomback to summary
private BooleanProperty showBottom
tipsback to summary
private final StringProperty tips
warningThresholdback to summary
private final DoubleProperty warningThreshold

Constructor Detail

LimitedTextAreaback to summary
public LimitedTextArea()
LimitedTextAreaback to summary
public LimitedTextArea(String text)

Method Detail

characterRangeLimitPropertyback to summary
public final ObjectProperty<IntegerRange> characterRangeLimitProperty()

The character range limit property defines the minimum and maximum number of characters allowed in the text area.

Returns:ObjectProperty<IntegerRange>

the character range limit property

createDefaultSkinback to summary
protected Skin<?> createDefaultSkin()

Overrides com.dlsc.gemsfx.ResizableTextArea.createDefaultSkin.

Doc from javafx.scene.control.TextArea.createDefaultSkin.

Create a new instance of the default skin for this control. This is called to create a skin for the control if no skin is provided via CSS -fx-skin or set explicitly in a sub-class with setSkin(...).

Annotations
@Override
getCharacterRangeLimitback to summary
public final IntegerRange getCharacterRangeLimit()
getClassCssMetaDataback to summary
public static List<CssMetaData<? extends Styleable, ?>> getClassCssMetaData()

Hides javafx.scene.control.TextArea.getClassCssMetaData.

Doc from javafx.scene.control.TextArea.getClassCssMetaData.

Gets the CssMetaData associated with this class, which may include the CssMetaData of its superclasses.

getControlCssMetaDataback to summary
public List<CssMetaData<? extends Styleable, ?>> getControlCssMetaData()

Overrides javafx.scene.control.TextArea.getControlCssMetaData.

Doc from javafx.scene.control.TextArea.getControlCssMetaData.

Gets the unmodifiable list of the control's CSS-styleable properties.

Annotations
@Override
getExcludedItemsback to summary
public final ObservableList<String> getExcludedItems()
getLengthDisplayModeback to summary
public final LimitedTextArea.LengthDisplayMode getLengthDisplayMode()
getTipsback to summary
public final String getTips()
getUserAgentStylesheetback to summary
public String getUserAgentStylesheet()

Overrides com.dlsc.gemsfx.ResizableTextArea.getUserAgentStylesheet.

Doc from javafx.scene.layout.Region.getUserAgentStylesheet.

An implementation may specify its own user-agent styles for this Region, and its children, by overriding this method. These styles are used in addition to whatever user-agent stylesheets are in use. This provides a mechanism for third parties to introduce styles for custom controls.

The URL is a hierarchical URI of the form [scheme:][//authority][path]. If the URL does not have a [scheme:] component, the URL is considered to be the [path] component only. Any leading '/' character of the [path] is ignored and the [path] is treated as a path relative to the root of the application's classpath.

Subclasses overriding this method should not assume any particular implementation approach as to the number and frequency with which it is called. For this reason, attempting any kind of dynamic implementation (i.e. returning different user agent stylesheet values) based on some state change is highly discouraged, as there is no guarantee when, or even if, this method will be called. Some JavaFX CSS implementations may choose to cache this response for an indefinite period of time, and therefore there should be no expectation around when this method is called.



package com.example.javafx.app;

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class MyApp extends Application {

    @Override public void start(Stage stage) {
        Scene scene = new Scene(new Group());
        scene.getStylesheets().add("/com/example/javafx/app/mystyles.css");
        stage.setScene(scene);
        stage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}
For additional information about using CSS with the scene graph, see the CSS Reference Guide.
Annotations
@Override
getValidWarningThresholdback to summary
public final double getValidWarningThreshold()
getWarningThresholdback to summary
public final double getWarningThreshold()
isOutOfRangeback to summary
public final boolean isOutOfRange()
isShowBottomback to summary
public final boolean isShowBottom()
lengthDisplayModePropertyback to summary
public final ObjectProperty<LimitedTextArea.LengthDisplayMode> lengthDisplayModeProperty()

The length display mode property defines when the text length indicator label should be displayed. LengthDisplayMode#AUTO, LengthDisplayMode#ALWAYS_SHOW, LengthDisplayMode#ALWAYS_HIDE

Returns:ObjectProperty<LimitedTextArea.LengthDisplayMode>

the length display mode property

outOfRangePropertyback to summary
public final ReadOnlyBooleanProperty outOfRangeProperty()

A read-only property indicating whether the text content is over the maximum length or under the minimum length.

setCharacterRangeLimitback to summary
public final void setCharacterRangeLimit(IntegerRange characterRangeLimit)
setLengthDisplayModeback to summary
public final void setLengthDisplayMode(LimitedTextArea.LengthDisplayMode lengthDisplayMode)
setOutOfRangeback to summary
private final void setOutOfRange(boolean outOfRange)
setShowBottomback to summary
public final void setShowBottom(boolean showBottom)
setTipsback to summary
public final void setTips(String tips)
setWarningThresholdback to summary
public final void setWarningThreshold(double warningThreshold)
showBottomPropertyback to summary
public final BooleanProperty showBottomProperty()
tipsPropertyback to summary
public final StringProperty tipsProperty()

The tips property used to display a hint or description of the text area.

warningThresholdPropertyback to summary
public final DoubleProperty warningThresholdProperty()

The warning threshold is a value between 0 and 1. When the text length is greater than or equal to the maximum length times the warning threshold, the warning style will be applied.

com.dlsc.gemsfx back to summary

public final Enum LimitedTextArea.LengthDisplayMode

extends Enum<LimitedTextArea.LengthDisplayMode>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final LimitedTextArea.LengthDisplayMode
ALWAYS_HIDE

Always hide the length indicator.

public static final LimitedTextArea.LengthDisplayMode
ALWAYS_SHOW

Always show the length indicator.

public static final LimitedTextArea.LengthDisplayMode
AUTO

When in a warning or error state, the text length indicator label will be displayed.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static LimitedTextArea.LengthDisplayMode
public static LimitedTextArea.LengthDisplayMode[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

ALWAYS_HIDEback to summary
public static final LimitedTextArea.LengthDisplayMode ALWAYS_HIDE

Always hide the length indicator.

ALWAYS_SHOWback to summary
public static final LimitedTextArea.LengthDisplayMode ALWAYS_SHOW

Always show the length indicator.

AUTOback to summary
public static final LimitedTextArea.LengthDisplayMode AUTO

When in a warning or error state, the text length indicator label will be displayed.

Constructor Detail

LengthDisplayModeback to summary
private LengthDisplayMode()

Method Detail

valueOfback to summary
public static LimitedTextArea.LengthDisplayMode valueOf(String name)
valuesback to summary
public static LimitedTextArea.LengthDisplayMode[] values()
com.dlsc.gemsfx back to summary

private Class LimitedTextArea.StyleableProperties

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private static final CssMetaData<LimitedTextArea, Boolean>
private static final List<CssMetaData<? extends Styleable, ?>>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

SHOW_BOTTOMback to summary
private static final CssMetaData<LimitedTextArea, Boolean> SHOW_BOTTOM
STYLEABLESback to summary
private static final List<CssMetaData<? extends Styleable, ?>> STYLEABLES

Constructor Detail

StyleablePropertiesback to summary
private StyleableProperties()