Question: Please edit this code to add three buttons, a clear button, pencil up button, and pencil down button while allowing the user to see where
Please edit this code to add three buttons, a clear button, pencil up button, and pencil down button while allowing the user to see where the pencil currently is on the screen. Please do so without changing the keycode up down left right part. Will thumbs up if it works.
import javafx.scene.Scene;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.input.KeyCode;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
import javafx.application.Application;
public class arrowdrawing extends Application
double x y;
final double SPEED;
@Override
public void startStage primaryStage
Pane pane new Pane;
Canvas canvas new Canvas;
GraphicsContext gc canvas.getGraphicsContextD;
pane.getChildrenaddcanvas;
x canvas.getWidth;
y canvas.getHeight;
gcmoveTox y;
Scene scene new Scenepane;
scene.setOnKeyPressede
if egetCode KeyCode.UP
y SPEED;
else if egetCode KeyCode.DOWN
y SPEED;
else if egetCode KeyCode.LEFT
x SPEED;
else if egetCode KeyCode.RIGHT
x SPEED;
gclineTox y;
gcstroke;
;
primaryStage.setScenescene;
primaryStage.show;
public static void mainString args
launchargs;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
