Two circles, with different radius and color, are drawn using Group layout.
In the Group layout, the positions, specified in the constructors, are followed.
package ex16;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.stage.Stage;
public class Ex16 extends Application {
@Override
public void start(Stage primaryStage) {
Group root = new Group();
Circle circ1 = new Circle(100, 100, 50, Color.RED);
Circle circ2 = new Circle(200, 200, 25, Color.BLUE);
root.getChildren().addAll(circ1, circ2);
Scene scene = new Scene(root, 400, 400, Color.HONEYDEW);
primaryStage.setTitle("Example 16. Group");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
This is the output:
No comments:
Post a Comment