Due to the print book page limit, we cannot inlcude all good CheckPoint questions in the physical book. The CheckPoint on this Website may contain extra questions not printed in the book. The questions in some sections may have been reordered as a result. Nevertheless, it is easy to find the CheckPoint questions in the book on this Website. Please send suggestions and errata to Dr. Liang at y.daniel.liang@gmail.com. Indicate the book, edition, and question number in your email. Thanks!

Chapter 14 Check Point Questions

Section 14.2
14.2.1
Explain the evolution of Java GUI technologies.
14.2.2
Explain why this book teaches Java GUI using JavaFX.
Section 14.3
14.3.1
How do you define a JavaFX main class? What is the signature of the start method? What is a stage? What is a primary stage? Is a primary stage automatically created? How do you display a stage? Can you prevent the user from resizing the stage? Can you replace Application.launch(args) by launch(args) in line 22 in Listing 14.1?
14.3.2
Show the output of the following JavaFX program.
import javafx.application.Application;
import javafx.stage.Stage;

public class Test extends Application {      
  public Test() {
    System.out.println("Test constructor is invoked");
  }

  @Override // Override the start method in the Application class
  public void start(Stage primaryStage) {
    System.out.println("start method is invoked");
  }

  public static void main(String[] args) {
    System.out.println("launch application");
    Application.launch(args);
  }
}
Section 14.4
14.4.1
How do you create a Scene object? How do you set a scene in a stage? How do you place a circle into a scene?
14.4.2
What is a pane? What is a node? How do you place a node in a pane? Can you directly place a Shape or an ImageView into a Scene? Can you directly place a Control or a Pane into a Scene?
14.4.3
How do you create a Circle? How do you set its center location and radius? How do you set its stroke color and fill color?
14.4.4
How do you replace the code in lines 20-21 in Listing 14.4 using one statement?
Section 14.5
14.5.1
What is a binding property? What interface defines a binding property? What interface defines a source object? What are the binding object types for int, long, float, double, and boolean? Are Integer and Double binding properties? Can Integer and Double be used as source objects in a binding?
14.5.2
Following the JavaFX binding property naming convention, for a binding property named age of the IntegerProperty type, what is its value getter method, value setter method, and property getter method?
14.5.3
Can you create an object of IntegerProperty using new IntegerProperty(3)? If not, what is the correct way to create it? What will the output if line 8 is replaced by d1.bind(d2.multiply(2)) in Listing 14.6? What will the output if line 8 is replaced by d1.bind(d2.add(2)) in Listing 14.6?
14.5.4
What is a unidirectional binding and what is bidirectional binding? Are all binding properties capable of bidirectional binding? Write a statement to bind property d1 with property d2 bidirectionally.
Section 14.6
14.6.1
How do you set a style of a node with border color red? Modify the code to set the text color for the button to red.
14.6.2
Can you rotate a pane, a text, or a button? Modify the code to rotate the button 15 degrees counterclockwise? How do you test if a point is inside a node? How do you scale up or down a node?
Section 14.7
14.7.1
How do you create a color? What is wrong about creating a Color using new Color(1.2, 2.3, 3.5, 4)? Which of two colors is darker, new Color(0, 0, 0, 1) or new Color(1, 1, 1, 1)? Does invoking c.darker() change the color value in c?
14.7.2
How do you create a Color object with a random color?
14.7.3
How do you set a circle object c with blue fill color using the setFill method and using the setStyle method?
Section 14.8
14.8.1
How do you create a Font object with font name Courier, size 20, and weight bold?
14.8.2
How do you find all available fonts on your system?
Section 14.9
14.9.1
How do you create an Image from a URL or a filename?
14.9.2
How do you create an ImageView from an Image, or directly from a file or a URL?
14.9.3
Can you set an Image to multiple ImageView? Can you display the same ImageView multiple times?
Section 14.10
14.10.1
How do you add a node to a Pane, StackPane, FlowPane, GridPane, BorderPane, HBox, and VBox? How do you remove a node from these panes?
14.10.2
How do you set the alignment to right for nodes in a FlowPane, GridPane, HBox, and VBox?
14.10.3
How do you set the horizontal gap and vertical hap between nodes in 8 pixels in a FlowPane and GridPane and set spacing in 8 pixels in an HBox and VBox?
14.10.4
How do you get the column and row index of a node in a GridPane? How do you reposition a node in a GridPane?
14.10.5
What are the differences between a FlowPane and an HBox or a VBox?
Section 14.11
14.11.1
How do you display a text, line, rectangle, circle, ellipse, arc, polygon, and polyline?
14.11.2
Write code fragments to display a string rotated 45 degrees in the center of the pane.
14.11.3
Write code fragments to display a thick line of 10 pixels from (10, 10) to (70, 30).
14.11.4
Write code fragments to fill red color in a rectangle of width 100 and height 50 with the upper-left corner at (10, 10).
14.11.5
Write code fragments to display a round-cornered rectangle with width 100, height 200with the upper-left corner at (10, 10), corner horizontal diameter 40, and corner vertical diameter 20.
14.11.6
Write code fragments to display an ellipse with horizontal radius 50 and vertical radius 100.
14.11.7
Write code fragments to display the outline of the upper half of a circle with radius 50.
14.11.8
Write code fragments to display the lower half of a circle with radius 50 filled with the red color.
14.11.9
Write code fragments to display a polygon connecting the following points: (20, 40), (30, 50), (40, 90), (90, 10), (10, 30), and fill the polygon with green color.
14.11.10
Write code fragments to display a polyline connecting the following points: (20, 40), (30, 50), (40, 90), (90, 10), (10, 30).
14.11.11
What is wrong in the following code?
public void start(Stage primaryStage) {   
  // Create a polygon and place it in the scene
  Scene scene = new Scene(new Polygon(), 400, 400);
  primaryStage.setScene(scene); // Place the scene in the stage
  primaryStage.show(); // Display the stage
}
Section 14.12
14.12.1
What will happen if lines 120-130 are removed in Listing 14.21? Run the DisplayClock class in Listing 14.20 to test it.