JavaFX学习:Scene和Node
作者:互联网
代码示例
public class Main extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
// 创建 Scene, 注:Scene 上面必须要有一个 Node!
Button button = new Button("一个按钮");
button.setPrefWidth(200);
button.setPrefHeight(200);
Group group = new Group();
group.getChildren().add(button);
Scene scene = new Scene(group);
// 关联 Stage 和 Scene
primaryStage.setScene(scene);
primaryStage.setTitle("JavaFX by bingyi");
primaryStage.setWidth(800);
primaryStage.setHeight(800);
primaryStage.show();
}
}
标签:Node,primaryStage,button,JavaFX,Scene,new,group,public 来源: https://www.cnblogs.com/wbyixx/p/14207999.html