Unlike its base class RichTextArea, the CodeArea requires a special kind of model to be used,
a CodeTextModel.
CodeArea:
CodeArea codeArea = new CodeArea();
codeArea.setWrapText(true);
codeArea.setLineNumbersEnabled(true);
codeArea.setText("Lorem\nIpsum");
Which results in the following visual representation:
CodeArea extends the RichTextArea class, meaning most of the functionality works as it does
in the base class.
There are some differences that should be mentioned:
applyStyle(),
will be ignored
CodeArea sets the leftDecoratorProperty() to support the line numbers,
so applications should not set or bind that property.
| Modifier and Type | Class and Description |
|---|---|
| private static class | CodeArea.
styleable properties |
| Modifier and Type | Field and Description |
|---|---|
| private StyleableObjectProperty | |
| private String | |
| private BooleanProperty | |
| private StyleableDoubleProperty | |
| private StyleableIntegerProperty |
| Access | Constructor and Description |
|---|---|
| public | CodeArea(CodeTextModel
the instance of model)CodeTextModel to useThis constructor creates the CodeArea with the specified |
| public |
| Modifier and Type | Method and Description |
|---|---|
| private CodeTextModel | |
| protected RichTextAreaSkin | createDefaultSkin()
Overrides jfx. Create a new instance of the default skin for this control. |
| private static Font | |
| public final ObjectProperty | |
| public static List | Returns: theCssMetaDataHides jfx. Gets the |
| public List | getControlCssMetaData()
Overrides jfx. Gets the unmodifiable list of the control's CSS-styleable properties. |
| public final Font | |
| public final double | |
| public final SyntaxDecorator | Returns: the syntax decorator value, or nullThis convenience method returns the syntax decorator value in the |
| public final int | |
| public final String | |
| public final boolean | |
| public final BooleanProperty | Returns: the line numbers enabled propertyDetermines whether to show line numbers. |
| public final DoubleProperty | Returns: the property instanceDefines the vertical space in pixels between lines. |
| public Object | queryAccessibleAttribute(AccessibleAttribute attribute, Object... parameters)
Overrides jfx. This method is called by the assistive technology to request the value for an attribute. |
| public final void | |
| public final void | |
| public final void | |
| public final void | setSyntaxDecorator(SyntaxDecorator
the syntax decorator d)This convenience method sets the decorator property in the |
| public final void | |
| public final void | |
| public final IntegerProperty | |
| protected void | validateModel(StyledTextModel m)
Overrides jfx. Validates the model property value. |
| font | back to summary |
|---|---|
| private StyleableObjectProperty<Font> font | |
| fontStyle | back to summary |
|---|---|
| private String fontStyle | |
| lineNumbers | back to summary |
|---|---|
| private BooleanProperty lineNumbers | |
| lineSpacing | back to summary |
|---|---|
| private StyleableDoubleProperty lineSpacing | |
| tabSize | back to summary |
|---|---|
| private StyleableIntegerProperty tabSize | |
| CodeArea | back to summary |
|---|---|
| public CodeArea(CodeTextModel model) This constructor creates the CodeArea with the specified
| |
| CodeArea | back to summary |
|---|---|
| public CodeArea() This constructor creates the CodeArea with the default | |
| codeModel | back to summary |
|---|---|
| private CodeTextModel codeModel() | |
| createDefaultSkin | back to summary |
|---|---|
| protected RichTextAreaSkin createDefaultSkin() Overrides jfx. Doc from javafx. 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
| |
| defaultFont | back to summary |
|---|---|
| private static Font defaultFont() | |
| fontProperty | back to summary |
|---|---|
| public final ObjectProperty The font to use for text in the
| |
| getClassCssMetaData | back to summary |
|---|---|
| public static List Hides jfx. Gets the
| |
| getControlCssMetaData | back to summary |
|---|---|
| public List Overrides jfx. Doc from javafx. Gets the unmodifiable list of the control's CSS-styleable properties.
| |
| getFont | back to summary |
|---|---|
| public final Font getFont() | |
| getLineSpacing | back to summary |
|---|---|
| public final double getLineSpacing() | |
| getSyntaxDecorator | back to summary |
|---|---|
| public final SyntaxDecorator getSyntaxDecorator() This convenience method returns the syntax decorator value in the
| |
| getTabSize | back to summary |
|---|---|
| public final int getTabSize() | |
| getText | back to summary |
|---|---|
| public final String getText() Returns plain text. This method returns an empty string when the model is
| |
| isLineNumbersEnabled | back to summary |
|---|---|
| public final boolean isLineNumbersEnabled() | |
| lineNumbersEnabledProperty | back to summary |
|---|---|
| public final BooleanProperty lineNumbersEnabledProperty() Determines whether to show line numbers.
Toggling this property results in changes made to the
| |
| lineSpacingProperty | back to summary |
|---|---|
| public final DoubleProperty lineSpacingProperty() Defines the vertical space in pixels between lines.
| |
| queryAccessibleAttribute | back to summary |
|---|---|
| public Object queryAccessibleAttribute(AccessibleAttribute attribute, Object... parameters) Overrides jfx. Doc from javafx. This method is called by the assistive technology to request the value for an attribute.
This method is commonly overridden by subclasses to implement
attributes that are required for a specific role.
| |
| setFont | back to summary |
|---|---|
| public final void setFont(Font value) | |
| setLineNumbersEnabled | back to summary |
|---|---|
| public final void setLineNumbersEnabled(boolean on) | |
| setLineSpacing | back to summary |
|---|---|
| public final void setLineSpacing(double spacing) | |
| setSyntaxDecorator | back to summary |
|---|---|
| public final void setSyntaxDecorator(SyntaxDecorator d) This convenience method sets the decorator property in the
| |
| setTabSize | back to summary |
|---|---|
| public final void setTabSize(int spaces) | |
| setText | back to summary |
|---|---|
| public final void setText(String text) Replaces text in this CodeArea. The caret gets reset to the start of the document and the selection gets cleared.
| |
| tabSizeProperty | back to summary |
|---|---|
| public final IntegerProperty tabSizeProperty() The size of a tab stop in spaces. Values less than 1 are treated as 1.
| |
| validateModel | back to summary |
|---|---|
| protected void validateModel(StyledTextModel m) Overrides jfx. Doc from jfx. Validates the model property value.
The subclass should override this method if it restricts the type of model that is supported,
and throw an
| |
| Modifier and Type | Field and Description |
|---|---|
| private static final FontCssMetaData | |
| private static final CssMetaData | |
| private static final List | |
| private static final CssMetaData |
| Access | Constructor and Description |
|---|---|
| private |
| FONT | back to summary |
|---|---|
| private static final FontCssMetaData<CodeArea> FONT | |
| LINE_SPACING | back to summary |
|---|---|
| private static final CssMetaData<CodeArea, Number> LINE_SPACING | |
| STYLEABLES | back to summary |
|---|---|
| private static final List<CssMetaData<? extends Styleable, ?>> STYLEABLES | |
| TAB_SIZE | back to summary |
|---|---|
| private static final CssMetaData<CodeArea, Number> TAB_SIZE | |
| StyleableProperties | back to summary |
|---|---|
| private StyleableProperties() | |