javafx.scene.Group如果设置setAutoSizeChildren为fasle,那么下面例子中的按钮将不能正常显示
package group;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.stage.Stage;
public class TestGroup3 extends Application {
@Override
public void start(Stage stage) throws Exception {
Group g = new Group();
Button btn = new Button("btn");
g.getChildren().add(btn);
g.setAutoSizeChildren(false);// 如果注释掉这句话,那么按钮将不会显示
stage.setScene(new Scene(g));
stage.show();
btn.setMinSize(20, 20);
btn.setPrefSize(30, 30);
}
public static void main(String[] args) {
launch(args);
}
}