The following program draws an bb-8 as shown below. modify the


The following program draws an BB-8 as shown below.  Modify the program to move the BB-8 left or right using the arrow keys.  The program can be download from the CMS. Please use Javafx 


import javafx.application.Application;

import javafx.scene.Scene;

import javafx.scene.input.KeyCode;

import javafx.scene.layout.Pane;

import javafx.scene.paint.Color;

import javafx.scene.shape.Circle;

import javafx.scene.shape.Line;

import javafx.stage.Stage;

public class MovingBB8 extends Application {

     @Override // Override the start method in the Application class

public void start(Stage primaryStage) { 

           BB8Pane pane = new BB8Pane();

           pane.setOnKeyPressed(e -> { 

               // Write code here


           // Create  scene and place it in the stage

           Scene scene = new Scene(pane, 400, 120);






class BB8Pane extends Pane {

private Circle circle1 = new Circle(200, 50, 15);

private Circle circle2 = new Circle(200, 70, 20);

private Line line = new Line(200, 25, 200, 35);

public BB8Pane() {




           getChildren().addAll(circle1, circle2, line);


public void moveLeft() {

           // Write  code here


public void moveRight() {

     // write  code here