Two circles, with different radius and color, are drawn using VBox layout.
The circle are laid vertically, with a spacing of 10 as defined in the constructor.
package ex15;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.stage.Stage;
public class Ex15 extends Application {
@Override
public void start(Stage primaryStage) {
VBox root = new VBox(10);
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 15. VBox");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
This is the output:
No comments:
Post a Comment