How To Draw A Circle In Javafx
How to create a circle using JavaFX?
A circumvolve is a line forming a closed loop, every bespeak on which is a fixed distance from a center point. A circle is defined by its middle and radius − distance from the center to any point on the circle.
In JavaFX a circumvolve is represented by the javafx.scene.shape.Circle class. This grade contains three properties they are −
-
centerX − This property represents the x coordinate of the centre of a circle, y'all can set the value to this belongings using the setCenterX() method.
-
centerY − This property represents y coordinate of the heart of a circle, you can set the value to this property using the setCenterY() method.
-
radius − The radius of the circumvolve in pixels, you can prepare the value to this property using the setRadius() method.
To create a circle you need to −
-
Instantiate the class Circle.
-
Set the required properties using the setter methods or, bypassing them equally arguments to the constructor.
-
Add the created node (shape) to the Group object.
Example
import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.paint.Color; import javafx.stage.Stage; import javafx.scene.shape.Circle; public form DrawingCircle extends Application { public void start(Phase stage) { //Drawing a Circumvolve Circle circle = new Circle(); //Setting the properties of the circle circumvolve.setCenterX(300.0f); circumvolve.setCenterY(135.0f); circle.setRadius(100.0f); //Setting other properties circle.setFill(Colour.DARKCYAN); circle.setStrokeWidth(8.0); circle.setStroke(Color.DARKSLATEGREY); //Setting the Scene Group root = new Group(circumvolve); Scene scene = new Scene(root, 595, 300, Color.Beige); stage.setTitle("Drawing a Circle"); stage.setScene(scene); stage.show(); } public static void principal(Cord args[]){ launch(args); } } Output
Published on 14-Apr-2020 07:45:xiv
- Related Questions & Answers
- How to create a Rectangle using JavaFX?
- How to create a Line using JavaFX?
- How to create a Polygon using JavaFX?
- How to create a Polyline using JavaFX?
- How to create a CubicCurve using JavaFX?
- How to create a QuadCurve using JavaFX?
- How to create a ComboBox using JavaFX?
- How to create a ColorPicker using JavaFX?
- How to create a Hyperlink using JavaFX?
- How to create a label using JavaFX?
- How to create a separator using JavaFX?
- How to create a Menu using JavaFX?
- How to create a ScrollBar using JavaFX?
- How to create a ListView using JavaFX?
- How to create a TreeView using JavaFX?
Source: https://www.tutorialspoint.com/how-to-create-a-circle-using-javafx
Posted by: washingtondishemeard.blogspot.com

0 Response to "How To Draw A Circle In Javafx"
Post a Comment