Question
Java programing help // Import library packages import javafx.application.Application; import javafx.scene.canvas.Canvas; import javafx.scene.Scene; import javafx.scene.Group; import javafx.stage.Stage; import javafx.scene.canvas.GraphicsContext; import javafx.scene.shape.ArcType; import javafx.event.EventHandler; import javafx.stage.WindowEvent;
Java programing help
// Import library packages import javafx.application.Application; import javafx.scene.canvas.Canvas; import javafx.scene.Scene; import javafx.scene.Group; import javafx.stage.Stage; import javafx.scene.canvas.GraphicsContext; import javafx.scene.shape.ArcType; import javafx.event.EventHandler; import javafx.stage.WindowEvent; import javafx.scene.paint.Color; import javafx.scene.text.Font;
/** class Triangle * * The important thing that we need to do in this class is finish the * 'start' method. */ public class Triangle extends Application { public static void main(String[] args) { // launching the JavaFx program and the start method launch(args); }//main /** the "start" method, that specifies what to draw on the screen * * This method needs to be updated */ @Override public void start(Stage primaryStage) throws Exception { //set up a canvas on a scene to draw something Group root = new Group(); Scene scene = new Scene(root); Canvas canvas = new Canvas(600, 600); GraphicsContext gc = canvas.getGraphicsContext2D(); //This statement draws a traingle, but it is not the shape you want. //Replace it with the correct code. gc.fillPolygon(new double[] {150, 200, 150}, new double[] {150, 150, 200}, 3);
//(((((( PLACE THE CODE HERE )))))
primaryStage.setOnCloseRequest(new EventHandler
Part 3: Draw triangles Open the Triangle class. Java's Graphics class does not include a method for drawing triangles. It does, however have a fillRolygon and stxokeRolygon methods. Read about these two methods in your textbook or on the Internet. Modify the start method in the Triangle.java file so that the following shape appears in window. Use blue color. checkpoint 3 (20 points): Run your program in front of your lab instructor or assistant
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started