기본적으로 사용자가 이름을 입력 할 수 있도록 텍스트 필드가있는 팝업 디스플레이가 있습니다. (결국 이름을 얻고 나중에 사용하지만 중요하지 않습니다.) 불행하게도, 텍스트 필드의 텍스트는 업데이트되지 않습니다 (그래픽 적으로 프로그램은 tf.getText()를 통해 입력 된 내용을 계속 가져올 수 있지만 텍스트 업데이트는 볼 수 없습니다). JavaFX TextField 업데이트 텍스트가 없습니다.
Stage window = new Stage();
window.initModality(Modality.APPLICATION_MODAL);
window.setTitle("Naming");
window.setMinWidth(300);
window.setMinHeight(200);
Label label = new Label();
label.setText("Please type a name");
Button submitButton = new Button("Submit");
TextField tf = new TextField();
tf.setText("Please enter a name");
tf.setMaxWidth(200);
submitButton.setOnAction(e ->{
System.out.println(tf.getText());
window.close();
});
VBox layout = new VBox(10);
layout.getChildren().addAll(label, submitButton, tf);
Scene scene = new Scene(layout);
window.setScene(scene);
window.showAndWait();
문제
는 changindwindow.showAndWait();
단지
window.show()
을 통해 해결 될 수 있지만, 그것은 또한 다른 방법으로 해결 될 수 있을지 궁금하네요.
이 도움말이 있습니까? (http://stackoverflow.com/questions/26022699/javafx-text-fields-are-not-updating-on-gui) –
제공 한 코드가 잘 작동합니다. 사용중인 Java 버전은 무엇입니까? JavaFX 스레드에 위의 코드? 앱을 지연시키는 Lock 또는 Thread.sleep() 메소드를 실행하고 있습니까? – GOXR3PLUS