A red circle with a radius of 100 and center 200,200 is drawn.
Since the scene is 400 by 400, it is centered on the window.
package ex05;
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 Ex05 extends Application {
@Override
public void start(Stage primaryStage) {
Circle circ = new Circle(
200, 200, // center x,y
100, // radius
Color.RED); // fill
Group root = new Group();
root.getChildren().add(circ);
Scene scene = new Scene(root, 400, 400, Color.AQUA);
primaryStage.setTitle("Example 5. Circle");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
This is the output:
No comments:
Post a Comment