import javafx.application.Application; import static javafx.application.Application.launch; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; import javafx.geometry.NodeOrientation; import javafx.scene.Scene; import javafx.scene.control.PasswordField; import javafx.scene.control.ToggleButton; import javafx.scene.layout.VBox; import javafx.stage.Stage; public class PasswordFieldSelectAll extends Application{ private void init(Stage primaryStage) { VBox root = new VBox(); Scene scene = new Scene(root, 400, 200); primaryStage.setScene(scene); PasswordField password = new PasswordField(); ToggleButton rtlButton = new ToggleButton("RTL Orientation"); rtlButton.selectedProperty().addListener(new ChangeListener() { public void changed(ObservableValue ov, Boolean t, Boolean t1) { password.setNodeOrientation(t1 ? NodeOrientation.RIGHT_TO_LEFT : NodeOrientation.INHERIT); } }); root.getChildren().addAll(password, rtlButton); } @Override public void start(Stage primaryStage) throws Exception { init(primaryStage); primaryStage.setTitle("PasswordField Test " + System.getProperty("javafx.runtime.version")); primaryStage.show(); } public static void main(String[] args) { launch(args); } }