Write a JavaFX program that allows a user to moves a rectangle UP, DOWN, LEFT or RIGHT using the arrow keys. Move a rectangle Discuss: 1. Which of the following registrations methods can you use to...


java


Write a JavaFX program that allows a user to moves a rectangle UP, DOWN, LEFT or RIGHT<br>using the arrow keys.<br>Move a rectangle<br>Discuss:<br>1. Which of the following registrations methods can you use to register an<br>EventHandler by the rectangle object for this program?<br>setOnkeyPressed, setOnkeyReleased or setOnkeyTyped<br>2. Since you are going to use keys, how you can move the focus to the<br>rectangle? Is using the rectangle object's setFocusTraversable(true) method<br>would help you?<br>3. How can you determine which arrow keys is pressed? Is using the KeyEvent<br>object's getCode() method would help you? Do you need to compare the<br>returned value by getCode() with one of the four arrow keys' constants in the<br>KeyCode class?<br>4. If the pressed arrow key is Up or Down, which rectangle coordinate you<br>should update? X or Y ( setx or setY method ).<br>5. If the pressed arrow key is Left or Right, which rectangle coordinate you<br>should update? X or Y ( setX or setY method ).<br>Part of the UML class diagram of KeyEvent class along with part of KeyCode<br>class's constants list are given in the next page.<br>

Extracted text: Write a JavaFX program that allows a user to moves a rectangle UP, DOWN, LEFT or RIGHT using the arrow keys. Move a rectangle Discuss: 1. Which of the following registrations methods can you use to register an EventHandler by the rectangle object for this program? setOnkeyPressed, setOnkeyReleased or setOnkeyTyped 2. Since you are going to use keys, how you can move the focus to the rectangle? Is using the rectangle object's setFocusTraversable(true) method would help you? 3. How can you determine which arrow keys is pressed? Is using the KeyEvent object's getCode() method would help you? Do you need to compare the returned value by getCode() with one of the four arrow keys' constants in the KeyCode class? 4. If the pressed arrow key is Up or Down, which rectangle coordinate you should update? X or Y ( setx or setY method ). 5. If the pressed arrow key is Left or Right, which rectangle coordinate you should update? X or Y ( setX or setY method ). Part of the UML class diagram of KeyEvent class along with part of KeyCode class's constants list are given in the next page.

Jun 07, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here