Question: JAVA create a new Java class, Ant, that draws the path of an ant that is walking randomly around a JavaFX window. This should look
JAVA create a new Java class, Ant, that draws the path of an ant that is walking randomly around a JavaFX window. This should look a little like a scribbling on a page. If the ant walks off the edge of the screen re-center the ant and continue the random walk. Use the basic template from the code from lecture X01. In addition to that, you may find the following helpful:
... primaryStage.setScene(scene);
Timeline timeline = new Timeline(new KeyFrame(Duration.millis(100), ae -> { /* your code goes here */ })); timeline.setCycleCount(Animation.INDEFINITE); timeline.play(); primaryStage.show(); ...
lecture
public class JavaFXSquare extends javafx.application.Application @override public void start(Stage primaryStage) throws Exception f primaryStage.setTitle ("Sqaure"); Group root new Group); Scene scene = new Scene (root, width 300, height: 300); primaryStage.setscene(scene) height: 100); Rectangle r = new Rectangle( r.setFill(color.RED); root.getChildren ( ) .add(r);1 x: 100, y: 100, width: 100, primaryStage. show)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
