我在JavaFx上有一个简单的应用程序,只有VBox中的button和TextField。当我启动它时,窗口在右侧显示一个空白区域。我怎么解决这个问题?
public class FxTest extends Application {
Stage window;
Scene scene1;
@Override
public void start(Stage stage) throws Exception {
window = stage;
TextField tf = new TextField();
Button b = new Button("click");
b.setOnAction(e -> System.out.println(tf.getText()));
VBox layout = new VBox();
layout.getChildren().addAll(tf, b);
layout.setPadding(new Insets(20));
scene1 = new Scene(layout, 200, 300);
window.setScene(scene1);
window.show();
}
public static void main(String[] args) {
launch(args);
}
}