Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I I finish Q1 i need from you to solve Q2 only : ********************************************************************* import javafx.application.Application; import javafx.geometry.Orientation; import javafx.scene.Scene; import javafx.scene.layout.Pane; import javafx.scene.layout.Priority; import

image text in transcribedI I finish Q1 i need from you to solve Q2 only :

*********************************************************************

import javafx.application.Application; import javafx.geometry.Orientation; import javafx.scene.Scene; import javafx.scene.layout.Pane; import javafx.scene.layout.Priority; import javafx.scene.layout.VBox; import javafx.scene.paint.Color; import javafx.scene.shape.Line; import javafx.scene.shape.Rectangle; import javafx.stage.Stage;

/** * * @author DAYAN IT */ public class Part3 extends Application{

@Override public void start(Stage primaryStage) throws Exception { Pane pane = new Pane(); Rectangle upper =new Rectangle(140,100,120,100); upper.setFill(null); upper.setStroke(Color.BLACK); Rectangle lower =new Rectangle(100,140,120,100); lower.setFill(null); lower.setStroke(Color.BLACK); Line ul = new Line(140,100,100,140); Line ur = new Line(260,100,220,140); Line ll = new Line(140,200,100,240); Line lr = new Line(260,200,220,240); pane.getChildren().addAll(upper,lower,ul,ur,ll,lr); Pane pane1 = new Pane() { @Override public Orientation getContentBias() { return Orientation.VERTICAL ; } @Override public double computePrefWidth(double height) { return height ; } }; VBox container = new VBox(pane); container.setFillWidth(false); VBox.setVgrow(pane, Priority.SOMETIMES);

Scene s =new Scene(pane,300,300); primaryStage.setScene(s); primaryStage.setTitle("Cube"); primaryStage.setScene(new Scene(container, 600, 400)); primaryStage.show(); } public static void main(String[] args) { launch(args); } }

Okay, Thank you agian

- + X Project Work - Updated.pdf X Lab9- JavaFX Basics.pdf it C:/Users/DAYAN%201T/Downloads/ITDR2104-FL20/ITDR2104-FL20/ITDR2104_Labs_FL20/Lab9-%20JavaFX%20Bas... dl. O TURZ104 - Programming A Lau Part 3: Working with JavaFX Shapes and Binding Properties 1. Write a JavaFX program that displays a cube as shown below Hint: Cube X 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Organizing Information Digital And Information Literacy

Authors: Greg Roza

1st Edition

1448805929, 978-1448805921

More Books

Students also viewed these Databases questions