Question: help about java application the original code is i need to add at least 4 buttons centered along the top of the window that will
help about java application the original code is
i need to add at least 4 buttons centered along the top of the window that will allow a user to change the colour of the lines (e.g., red, blue, green, purple) and the output like
import javafx.application.Application; import javax.scene. Scene: import javafx.scene. Group; import javafx.scene.paint.Color; import javafx.scene. shape.*; import javafx.stage.Stage; import javafx.scene.input.MouseEvent; public class ElasticLines extends Applicationf private Line line; private Group root: Override public void start (Stage primaryStage)f root = new Group(); scene scene new scene (root, 500, 500,Color.LIGHTBLUE); scene.setonMousePressed (this::processMousePress): scene.setonMouseDragged (this:processMouseDrag) primaryStage.setTitle ("Elastic Lines"); primaryStage.setscene (scene) primaryStage. show ) public void processMousePress (MouseEvent e)f e . getX ( ) , e . getY ( ) ) ; line-new Line (e. getX ( ) , e . getY ( ) , line.setStroke (Color.RED) line.setStrokeWidth (3) root.getChildren () .add (1ine) public void processMouseDrag (MouseEvent e) line.setEndx (e.getX )) line.setEndY (e.getY)) public static void main (String[] args) i Application.launch (args)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
