Working with FXML Flashcards

1
Q

What is FXM

A

FX Markup Language.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

When using FXML, are you using a declarative approach or imperative.

A

Declarative.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Fill the blank: JavaFX provides FXML as a ______ for describing the layout and structuring the content of graphical user interfaces.

A

framework

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does the FXMLLoader class do?

A

The FXMLLoader class exposes public methods for translating
an FXML-based description of scene graph into its respective
in-memory object hierarchy.
▪ The FXMLLoader class reads an FXML file, validates it, and creates a
scene graph for the declared UI (it does not create a window or a
Stage!)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How does FXMLLoader work exactly? Name it’s four steps.

A

1: JavaFX application invokes FXMLLoader.
2: FXMLLoader parses the .fxml file and builds the scene graph.
3: FXMLLoader binds a controller to FXML, performs fields injection, and
calls controller’s initialize() method.
4: FXMLLoader builds scene graph and sends it to JavaFX application.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Describe the general four steps of working with FXML when making a UI.

A
  1. Design the UI on paper.
  2. Create the UI using Scene Builder
    - Add UI components
    - Set fx:id for each component
    - Set event handlers (optional) – or set in controller
  3. Create a Controller Java class:
    - Create references for UI controls and annotate them with @FXML
    - Declare event handler methods & implement the initialize() method
  4. Use the FXMLLoader to generate the scene graph
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

The FXML document defines the UI components, layout, and property values. Does it define the behavior and event handlers as well?

A

No it doesn’t.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

When using FXML to create your scene graph, how do you handle events?

A

You create a java Controller class to handle those events and provide behavior.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How do you connect references and objects?

A

1: In the FXML file (or using Scene Builder), we assign objects an “fx:id”
2: The value of the “fx:id” must be the name of a variable in the Controller class annotated with @FXML

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Name the four steps in loading a scene graph from FXML.

A

1) Instantiate the FXMLLoader and pass to its constructor the
path and file name of the FXML document you want to load.
2) Instantiate and set the Controller to the loader.
3) Call the loader’s load() method.
4) Set the returned scene graph to the scene.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly