package helloworld; import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.canvas.Canvas; import javafx.scene.canvas.GraphicsContext; import javafx.scene.paint.Color; import javafx.stage.Stage; public class polyTest extends Application { int size=512; @Override public void start(Stage primaryStage) throws Exception { primaryStage.setTitle("Hello Rectangle"); Canvas canvas = new Canvas(300,300); GraphicsContext g = canvas.getGraphicsContext2D(); g.setFill(Color.RED); double xPoints[] = new double[size]; double yPoints[] = new double[size]; for(int i = 0; i < size; i++) { xPoints[i] = Math.random() * 300; yPoints[i] = Math.random() * 300; } g.fillPolygon(xPoints, yPoints, size); Group root = new Group(); Scene scene = new Scene(root, 600, 450); scene.setFill(Color.LIGHTGREEN); root.getChildren().add(canvas); primaryStage.setScene(scene); primaryStage.show(); } public static void main(String args[]) { launch(args); } }