XTextField

XTextField extends the regular TextField class and enables you to add leading/trailing nodes inside the text field. Another feature is the clearable button on the right side which allows you to remove any text input. Leading and trailing controls are placed within a styleable container - see XTextField CSS Reference.

The screenshot was taken from XTextFieldDemo - the Demo can be downloaded from the link below.

XTextField field = new XTextField("JohnDoe");
field.setPromptText("Username");
field.setPrefWidth(250);
centerPane.getChildren().add(field);
        
Label l = new Label("@jyloo.com");
l.setStyle("-fx-text-fill: #48B");
field.addTrailingNode(l);

See also

Download XTextField Demo
CSS Reference - XTextField