JavaFx-Pane

Program

 

Program Source

import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.Group;
import javafx.scene.shape.Circle;
import javafx.scene.shape.Rectangle;
import javafx.scene.paint.Color;
import javafx.scene.layout.Pane;
import javafx.scene.layout.Background;
import javafx.scene.layout.BackgroundFill;

public class JavaFXApplication extends Application {

    public void start(Stage primaryStage) {
        
        primaryStage.setTitle("Pane");
        
        Group root = new Group();
        Scene scene = new Scene(root, 700, 200, Color.GREY);
        
        Pane pane = new Pane();
        pane.setBackground(new Background(new BackgroundFill(Color.BLACK,null,null)));
        pane.setLayoutX(200);
        
        Circle circle = new Circle();
        circle.setFill(Color.AQUA);
        circle.setCenterX(100);
        circle.setCenterY(100);
        circle.setRadius(100);
        
        Rectangle rect = new Rectangle();
        rect.setFill(Color.SALMON);
        rect.setX(200);
        rect.setY(50);
        rect.setWidth(100);
        rect.setHeight(100);
        
        pane.getChildren().addAll(circle,rect);
        
        root.getChildren().addAll(pane);
        primaryStage.setScene(scene);
        primaryStage.show();
    }
}

Leave a Comment