1/129
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
Can you load a single Image instance with multiple ImageViews?
Yess.
What is the graphical tool that helps with JavaFX UI design?
SceneBuilder.
What is the declarative language used for constructing JavaFX applications?
FXML.
What is the web component that uses WebKitHTML technology to embed web pages within JavaFX?
WebView.
Can existing Swing applications be updated with JavaFX features?
Yes.
How do you directly draw images in JavaFX?
Using the canvas API.
How do you physically print nodes in JavaFX?
Using the printing API.
Does JavaFX support multitouch handheld devices?
Yess.
What is AWT?
Abstract window toolkit. The original Java desktop application framework.
What is Swing?
Swing replaced AWT as the Java desktop application framework.
What is a build system?
Build systems help with software project management, managing the configuration of dependencies. It automates the process of generating a software build for delivery. There is no need to manually add JAR files.
e.g. Maven, Gradle.
What is the essential framework for writing JavaFX programs?
The javafx.application.Application class.
What files are automatically generated when creating a JavaFX project (in IntelliJ)?
HelloApplication.java
HelloController.java
hello-view.fxml
What static method in the Application class launches the JavaFX application?
launch()
Is the main() method necessary to run a JavaFX program?
Not if you run it from the command line.
What method is overridden in the HelloApplication class (created by IntelliJ upon project creation)?
start()
What is a Stage?
The window for displaying a scene that contains Node objects. It is the parameter of the start() method.
How do you set a scene to a Stage?
stage.setScene(scene);
What is a Scene?
A component tree composed of Node objects.
What is a Node?
A visual component on the UI like a shape, UI control, group, or pane.
What are the 3 basic features each Node has in JavaFX?
1. ID
2. Style class
3. Bounding volume
It can also have effects, transforms, etc.
What is the scene graph?
A set of Nodes in the form of a tree. Basically, it describes the GUI structure.
Can a scene graph have cycles?
No.
What transformations can be applied to Nodes?
Translation: Shifting along the x-axis or y-axis.
Rotation: Rotation about a pivot point.
Scaling: Scales the size of the Node.
Shearing: Rotates one axis so that the x-axis and y-axis are no longer perpendicular.
What is a Parent?
The root Node of the component tree.
What is a branch Node?
A Node that can have children. These Nodes are of type Parent, like Group, Pane, and Control.
What is a leaf Node?
Classes that cannot have children, like Rectangle, Text, and Label.
What is a root Node?
A Node with no Parent Node.
Can a Node occur multiple times in the scene graph?
No.
How do you create Scene objects?
new Scene(Parent root);
new Scene(Parent root, double width, double height);
By default, can the user resize the stage?
Yes.
stage.setResizable(false) disables this.
What is a Shape?
A text, line, circle, rectangle, arc, etc.
What are Panes?
Layouts that organize the Nodes.
What are UI controls?
Interactive Nodes like Labels, CheckBox, RadioButton, etc.
What is a group?
A container that groups collections of nodes. You can apply transformations or effects to a group which automatically apply to all the children Nodes in the group.
What is the inheritance relationship between Node and its child classes?
Node
Parent
Group, Pane, Control
Pane consists of classes ending in "Pane" (except TabPane).
Control consists of UI controls like Button, RadioButton, etc.
Group is just a collection of Nodes.
How do you create a Scene?
new Scene(Parent root);
OR
new Scene(Parent root, double width, double height);
What is a Property?
Values wrapped in classes.
centerXProperty() returns a Property object.
getCenterX() returns the actual value of that Property object.
What is property binding?
Binding a target object (binding property) to a source object (observable object), where a change in the observable object is automatically reflected in the binding property.
What is a binding property?
The target object that reacts to changes.
What is an observable object?
The source object where the changes originate.
What is an ObservableValue?
The whole value that the binding property is set to.
circle.centerYProperty().bind(pane.heightProperty().divide(2));
Which is the binding property? Which is the observable object? Which is the ObservableValue?
Binding property: centerXProperty() and centerYProperty()
Observable object: widthProperty() and heightProperty()
ObservableValue: pane.widthProperty().divide(2) and pane.heightProperty().divide(2)
circle.centerYProperty().bind(pane.heightProperty().divide(2));
What type is centerYProperty()?
A DoubleProperty.
There are similarly IntegerProperty, StringProperty, etc. types.
What do common properties look like in FXML?
-fx-style, -fx-rotate, etc.
How do you paint a node?
Use the immutable Color class, which is a subclass of Paint. Color is IMMUTABLE.
How do you create a Color object?
new Color(double red, double green, double blue, double opacity);
Values range from 0.0 to 1.0.
How can you brighten or darken Colors?
brighter() and darker(). The opacity values remain the same.
How can you set the Font in a UI control?
Use the Font class. Defined by name, weight, posture, and size.
e.g. label.setFont(Font.font("Arial", FontWeight.BOLD, FontPosture.ITALIC, 20));
How do you represent an Image?
The Image class represents an image. Use the ImageView class to display an Image from a local directory or URI.
Image image = new Image("image/us.gif");
ImageView imageView = new ImageView(image);
OR
ImageView imageView = new ImageView();
imageView.setImage(image);
What are the two places you can load an Image from?
A directory or a URI.
How do you create an Image button?
Add a Button, add an ImageView as its child Node, and use button.setGraphic(imageView) to display the Image on the Button.
What are the containers for holding Nodes?
Group and Pane classes.
Are Panes and UI control objects resizable?
Yes.
Are Group, Shape, and text objects resizable?
No.
What Pane subclasses are there?
AnchorPane: Arranges Nodes offset from the top, bottom, left, and right edges of the Pane.
BorderPane: Arranges Nodes in top, bottom, left, right, and center regions.
FlowPane: Arranges Nodes from left to right, wrapping at the edge of the Pane.
GridPane: Arranges Nodes in a grid formation according to row and column indices.
HBox: Arranges Nodes in a single horizontal row.
StackPane: Arranges Nodes stacked on top of each other.
TilePane: Arranges Nodes in a grid of uniformly sized tiles.
VBox: Arranges Nodes in a single vertical row.
How do you add Nodes to a Pane?
pane.getChildren().add(node);
OR
pane.getChildren().addAll(node1, node2, node3);
How can you display Text?
Use the Text class. It displays a String at a starting point (x, y).
What are the basic properties of the Shape class?
fill, stroke, strokeWidth.
stroke and strokeWidth correspond to the color and width of the outline.
What Shape subclasses are there?
Arc
Circle
CubicCurve
Ellipse
Line
Path
Polygon
Polyline
QuadCurve
Rectangle
SVGPath
How can you create a Line?
Use the Line class. It displays a Line using parameters startX, startY, endX, and endY.
What are some commonalities among Shape subclasses?
centerX, centerY, radius.
What Shapes have Arcs?
Rectangle, Circle, Ellipse.
How are Arc angles measured?
In degrees. 0 is the rightmost edge of the circle.
What's the difference between Polygon and Polyline?
Polygon encloses a shape. Polyline doesn't enclose a shape.
What is the inheritance relationship between Node and its UI control child classes?
Node
Parent
Control
Labeled (Label, ButtonBase (Button, CheckBox, ToggleButton (RadioButton)))
TextInputControl (TextArea, TextField (PasswordField))
ComboBoxBase (ComboBox)
ListView
ScrollBar
Slider
Are ImageView and MediaView UI controls?
No, they are not. UI controls are typically interactive.
What is a ButtonBase?
The base class for Buttons, ToggleButtons, and CheckBoxes.
Where do the properties that Buttons and CheckBoxes have come from?
Labeled.
What are the useful methods for Label?
setText("text")
getText()
What are the useful methods for CheckBox, ToggleButton, and RadioButton?
isSelected()
setSelected(true/false)
setDisable(true/false)
What is the difference between parent class ToggleButton and subclass RadioButton?
ToggleButton is rendered as a Button. RadioButton has a dot to show toggle status.
What should you do to ensure ToggleButtons and RadioButtons are in the same group?
Create a ToggleGroup.
setToggleGroup() for each button.
What Node subclass should you use for entering passwords?
Use PasswordField over TextField.
What are the useful methods for TextField, PasswordField, and TextArea?
setText("text")
getText()
setDisable(true/false)
setEditable(true/false)
What Node subclass should you use for entering multiple lines of text?
Use TextArea over multiple TextFields.
What Node subclass should you use for entering dates?
DatePicker.
What Node subclass should you use for implementing a list of items?
ListView. This Node allows you to put items in rows.
What Node subclass should you use for implementing tables (like Excel) in JavaFX?
TableView. This Node is basically a ListView but with support for columns.
What is a ComboBox?
A dropdown list containing items.
How do you add or remove a single item to a ComboBox or ListView?
listview.getItems().add(item)
listview.getItems().remove(item)
How do you add multiple items to a ComboBox or ListView?
listview.getItems().addAll(
Color.RED,
Color.GREEN,
Color.BLUE
);
You can also add an ObservableList
listview.setItems(observableList);
What is a SelectionMode?
An enum used to specify how many items can be selected in Nodes like ComboBox.
SelectionMode.SINGLE
SelectionMode.MULTIPLE
How do you get selected items from Nodes like ComboBox and ListView?
You MUST get the selection model first.
e.g. comboBox.getSelectionModel.getSelecteditem();
What Node subclass should you use for implementing scrolling?
ScrollBar.
What Node subclass should you use for implementing audio and video playing?
MediaPlayer controls the media.
MediaView provides a view of the Media played by MediaPlayer.
What do you call something like a Button that generates an event?
Event source object.
What is an event?
An object created from an event source object.
How do you process events like a button click, mouse movement, or keystrokes?
Use an event handler.
How do you register an event handler with an event source object?
button.setOnAction(handler);
OR
button.setOnMousePressed(handler);
OR
button.setOnKeyPressed(handler);
What two requirements are necessary to be the handler for an action event?
1. Be an instance of the EventHandler interface.
2. Be registered with the event source object (e.g. Button).
What is the inheritance relationship between EventObject and its subclasses?
EventObject
Event (ActionEvent, WindowEvent, InputEvent (MouseEvent, KeyEvent)
How do you identify an event source object?
getSource()
What kind of model does Java use for event handling?
A delegation-based model.
What is fired when a mouse button is pressed, released, clicked, moved, or dragged?
A MouseEvent object. It captures the number of clicks, x and y coordinates, or which button was pressed.
What is fired when a key is pressed, released, clicked, moved, or dragged?
A KeyEvent object. It captures the value of the key and the nature of the event (press or release).
How does a Listener work?
When an Observable object is changed, the Listener is notified by invoking its invalidated(Observable o) method.
What is an inner class?
A class defined within the scope of another class.
What filename format is an inner class compiled into?
OuterClass$InnerClass.class
Is this valid syntax for an inner class?
public void methodName() {
class InnerClass implements SomeInterface {
private String message = "hi";
void printMessage() {
System.out.println(message);
}
Yes.