Set TextField width in JavaFX
Just set this methods after you create the TextField:
TextField myTf = new TextField();
myTf.setPrefWidth(80);
myTf.setMaxWidth(80);
Works pretty fine:
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.TextField;
import javafx.stage.Stage;
public class TextFieldWidthApp extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
TextField userTextField = new TextField();
userTextField.setPrefWidth(800);
primaryStage.setScene(new Scene(userTextField));
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}