Java Circle.setCenterX(double value)

Syntax

Circle.setCenterX(double value) has the following syntax.

public final void setCenterX(double value)

Example

In the following code shows how to use Circle.setCenterX(double value) method.


import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.effect.DropShadow;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.stage.Stage;
/*  ww  w  .  j  av  a  2s. co  m*/
public class Main extends Application {
  public static void main(String[] args) {
    Application.launch(args);
  }

  @Override
  public void start(Stage primaryStage) {
    primaryStage.setTitle("");
    Group root = new Group();
    Scene scene = new Scene(root, 300, 250, Color.WHITE);

    Group g = new Group();

    DropShadow ds1 = new DropShadow();
    ds1.setOffsetY(4.0);

    Circle c = new Circle();
    c.setEffect(ds1);
    c.setCenterX(50.0);
    c.setCenterY(125.0);
    c.setRadius(30.0);
    c.setFill(Color.RED);
    c.setCache(true);


    g.getChildren().add(c);
    

    root.getChildren().add(g);
    primaryStage.setScene(scene);
    primaryStage.show();
  }
}




















Home »
  Java Tutorial »
    javafx.scene.shape »




Arc
ArcBuilder
Circle
Ellipse
Line
Polygon
VLineTo