Question: 1. Write a JavaFX program that displays a cube as shown below Hint: Cube a. To draw a cube you need to draw two Rectangles

1. Write a JavaFX program that displays a cube as shown below Hint: Cube a. To draw a cube you need to draw two Rectangles object with the same width and height values but with two different starting positon (X start coordinate and Y start coordinate). The starting position is the top-left corner of the rectangle. b. Set both rectangles' filling color to white with opacity of zero and rectangles' stroke color to black. C. Then draw four lines between the corners of the two rectangles. For example, to draw the line between the top left corners of rectangles you may write: Line topLeftLine = new Line ( frontRectangle.getX(), frontRectangle.getY(), backRectangle.getX(), backRectangle.getY()); For the other lines you may need to add the width value or the height value of the rectangle to obtain the X or the Y coordinates of a corner. Use getWidth() to get the width of a rectangle and getHeight () to get the height of a rectangle. 2. Modify the program so the cube should grow and shrink as the window grows or shrinks. Hint: Use Binding Properties. a. Bind Rectangle Properties (X, Y, width and height) to Pane Properties (width and height). How can you use a pane's width and height to get a rectangle's X, Y, width and height? b. Bind Line Properties (startX, starty, endx and endy) to Rectangle Properties (X, Y, width and height). How can you use a rectangle's X, Y, width and height to get laine's startx, starty, endx and endY
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
