Implementing JavaFX shapes in different methods each

I have this working JavaFX code, that is used to draw four different shapes in a root frame. I would like each shape to have its own method that implements it, that is for instance if it is a circle, something like public void circle(){//statements} but I don't know how to do it. Please help me. Thank you.

package shapes;

import javafx.application.Application;

import javafx.scene.Group;

import javafx.scene.Scene;

import javafx.scene.paint.Color;

import javafx.scene.shape.Circle;

import javafx.scene.shape.Line;

import javafx.scene.shape.Polygon;

import javafx.scene.shape.Rectangle;

import javafx.stage.Stage;

/**

*

* @author mach

*/

public class Shapes extends Application {

@Override

public void start(Stage primaryStage) {

Group root = new Group();

//Draw a line

Line line= new Line();

line.setStartX(150);

line.setStartY(20);

line.setEndX(270);

line.setEndY(20);

line.setStroke(Color.RED);

//Draw a circle...

Read More »

By: StackOverFlow - Sunday, 16 September

Related Posts