Top Description Fields Constructors Methods
org.controlsfx.control.textfield

public Class CustomTextField

extends TextField
Class Inheritance
Imports
impl.org.controlsfx.skin.CustomTextFieldSkin, javafx.beans.property.ObjectProperty, .SimpleObjectProperty, javafx.scene.Node, javafx.scene.control.Skin, .TextField

A base class for people wanting to customize a TextField to contain nodes inside the text field itself, without being on top of the users typed-in text.

Screenshot

The following screenshot is taken from the HelloControlsFX sample application, and shows a normal TextField, with a clearable text field, followed by three CustomTextFields. Note what happens with long text input - it is prevented from going beneath the left and right graphics. Of course, if the keyboard caret moves to the right, the text will become visible, but this is because it will all scroll to the left (as is the case in a normal TextField).

Screenshot of CustomTextField
See Also
TextFields, CustomPasswordField

Field Summary

Modifier and TypeField and Description
private ObjectProperty<Node>
left

Hides javafx.scene.Parent.left.

Properties
private ObjectProperty<Node>
Inherited from javafx.scene.control.TextField:
DEFAULT_PREF_COLUMN_COUNT

Constructor Summary

AccessConstructor and Description
public
CustomTextField()

Instantiates a default CustomTextField.

Method Summary

Modifier and TypeMethod and Description
protected Skin<?>
createDefaultSkin()

Overrides javafx.scene.control.TextField.createDefaultSkin.

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

public final Node
getLeft()

Returns: the Node that is placed on the left of the text field.

public final Node
getRight()

Returns: The Node that is placed on the right of the text field.

public String
getUserAgentStylesheet()

Overrides javafx.scene.layout.Region.getUserAgentStylesheet.

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

public final ObjectProperty<Node>
leftProperty()

Returns: An ObjectProperty wrapping the Node that is placed on the left ofthe text field.

public final ObjectProperty<Node>

Returns:

An ObjectProperty.
rightProperty
()

Property representing the Node that is placed on the right of the text field.

public final void
setLeft(Node value)

Sets the Node that is placed on the left of the text field.

public final void
setRight(Node value)

Sets the Node that is placed on the right of the text field.

Inherited from javafx.scene.control.TextField:
alignmentPropertygetAlignmentgetCharactersgetClassCssMetaDatagetControlCssMetaDatagetOnActiongetPrefColumnCountonActionPropertyprefColumnCountPropertysetAlignmentsetOnActionsetPrefColumnCount

Field Detail

leftback to summary
private ObjectProperty<Node> left

Hides javafx.scene.Parent.left.

Properties

Constructor Detail

CustomTextFieldback to summary
public CustomTextField()

Instantiates a default CustomTextField.

Method Detail

createDefaultSkinback to summary
protected Skin<?> createDefaultSkin()

Overrides javafx.scene.control.TextField.createDefaultSkin.

Doc from javafx.scene.control.TextField.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
getLeftback to summary
public final Node getLeft()
Returns:Node

the Node that is placed on the left of the text field.

getRightback to summary
public final Node getRight()
Returns:Node

The Node that is placed on the right of the text field.

getUserAgentStylesheetback to summary
public String getUserAgentStylesheet()

Overrides javafx.scene.layout.Region.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
leftPropertyback to summary
public final ObjectProperty<Node> leftProperty()
Returns:ObjectProperty<Node>

An ObjectProperty wrapping the Node that is placed on the left ofthe text field.

rightPropertyback to summary
public final ObjectProperty<Node> rightProperty()

Property representing the Node that is placed on the right of the text field.

Returns:ObjectProperty<Node>

An ObjectProperty.

setLeftback to summary
public final void setLeft(Node value)

Sets the Node that is placed on the left of the text field.

setRightback to summary
public final void setRight(Node value)

Sets the Node that is placed on the right of the text field.