How I can set the width of a TextField
in JavaFX?
TextField userTextField = new TextField();
I tried this:
TextField userTextField = new TextField();
userTextField.setPrefWidth(80);
But I don't see any change.
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);
}
}