Exam 2 Flashcards
PTUI
Plain text user interfaces - command line interfaces
GUI
Graphical user interface - comprised of graphical controls
GUI toolkit used in class
JavaFX
Java’s original GUI toolkit
Abstract Window Toolkit - OS specific. Used heavyweight windows
Java Swing
GUI added in v. 1.2. lightweight and platform-independent.
GUI using JavaFX begins by __ the __ __.
Extending, Application class. Application is abstract.
The ___ is a window in which the JavaFX application runs
Stage
T/F: A stage is used to display a scene
True
T/F: Only one stage can exist at a time.
False. Additional stages show as separate windows. Primary is auto-created with start method
Scenes contain __, which can be __ or __
Single control. Widgets (button, label, text). Pane (container for other controls).
The graphical element that is the building block of a GUI
Control aka node
Control used to display a string of text
Label
JavaFX controls are highly __
Customizable
Some basic modifications to a label
setText(String)
setFont(Font)
setPadding(Insets)
Common stage sets
stage.setTitle(String)
stage.setScene(scene)
stage.show()
Controls can be customized __ and through the use of __
Programmatically. Cascading style sheets (CSS)
Layout
Container in which nodes can be added. Determines where the nodes are, including position and size. Layout is also a node.
Layout that arranges children from left to right
HBox
Layout that arranges children from top to bottom
VBox
To add children to an HBox or VBox
box.getChildren.add(Node)
T/F: HBox and VBox layouts automatically fill in extra space by default
False. Only use space each child needs. Use setMaxHeight(Double.POSITIVE_INFINITY) or width to adjust widgets
A __ method contains code to build some product
Factory. Anything that stays the same between outputs is placed in method. Changing factors in parameters.
Insets
Used to define extra space on the top, bottom, left, and right of something. Can be used within padding setting to achieve.
CornerRadii
Used to round corners on otherwise rectangular shapes
Border
Drawn around outside edges of a component
BorderPane
Divided into five regions: top, bottom, left, right, center. One node each max (last kept if multiple)
T/F: An empty region in a BorderPane will be invisible
True
GridPane
Organizes children into columns and rows (col first). Exact num doesn’t need specifying on instantiation.
T/F: In a GridPane, children can only exist in one location (col, row)
False. Nodes can expand using additional arguments on add method
gp.add(label, 3, 4, 1, 2)
TextField
Control in which user can type single line of text. Can include prompt text.
Button
Control that users can interact with using the mouse or keyboard. Created with text or image. Responds to mouse events (enter, exit, hover, click)
Trying to set a background for a button will…
Remove its default highlights and shading
Observer Design Pattern
When there is a subject of interest, it maintains a list of observers that will be notified when something happens.
EventHandler<T></T>
An observer interface that must be implemented by classes that want to be notified when an event occurs on a JavaFX control.
When using event handler, the real type that replaces the T must …
Extend the Event class. handle (T) called when event of interest occurs
ActionEvent
Used for button interaction. Button is subject. Observers must implement EventHandler<ActionEvent>. Can use button.setOnAction(EventHandler) to register to be notified</ActionEvent>
Image
Used to load and display images
Ways to load an image
- String URL, starting with “file:…”
- An InputStream
ImageView
Control just for displaying images. Cannot be added directly to a scene. Must have a parent.
StackPane
Stacks children one on top of the other in order added. Can be used to create a composite image.
Media
Class that represents an audio or video file. Source may be internet address or file in local system
Used to play media
MediaPlayer. Does not have a visual component
T/F: Labels can also be used to display graphics
True. Can set where image sits in relation to text
Grow Priority
Used for HBox and VBox to determine if child nodes will grow horizontally or vertically (respectively) to fill in extra space
Architecture
High level design that determines how the classes in a system are organized
MVC
Model View Controller is a pattern used when creating applications with user interfaces.
In MVC, the model
Basic building blocks of the app. Core elements and any logic needed to maintain or update the state of the application
In MVC, the view:
Part of the app the user can see. Represents current state of the model. Updated as model changes.
In MVC, the controller:
Core application logic. When input provided, it determines how to translate this action to the model. May also update the interface.
In GUIs some or all of the controller logic is often ___
Embedded in the GUI
A background can be set to an image using
BackgroundImage. If smaller than the control, image can be repeated
Practice of writing code that is executed in response to events is referred to as __
Event-Driven Programming
Abstract Data Type
Describes the behavior of data structure from user perspective without implementation details