48024 Lecture Notes - Lecture 9: Javafx, Scene Graph, Javabeans
Study 9 – Model View Controller
FXML
• In GridPanes hgap sets the horizontal gap between child nodes and vgap sets the
vertical gap between child nodes.
• A <Label> is used to label an input, whereas <Text> is used to display free-standing
text. The text of a <Label> can never change, whereas that of a <Text> can.
• The <stylesheets> element is placed within the root node of the scene graph to link
to the URL of the CSS file.
• You a assig a stle lass to a ode usig stleClass=z depedig o the
name of the style category in the CSS file.
Model-View-Controller
• The MVC pattern splits a GUI program into 3 layers.
o Models are Java objects that represent the data of your application and the
operations on that data
o Views are the components that represent the graphical user interface of the
appliatio. Vies osere data i the odels Whe odel data hages,
the views are notified so they can update the screen.
o Controllers are the components that handle user interaction. Controllers
osere eets that occur in the views. When user interaction happens in
the view, the controllers are notified so they can handle the event.
Model
• Contains data and related operations.
• Does not contain user interface code:
o No Read Pattern
o No Menu Pattern
o No Output Pattern
• Should provide getters and setters for the data
• A pair of getter and setter methods is called a JavaBeans property. A read-only
propert is a getter ithout a setter. A Boolea propert getter uses the prefi is
istead of get
• Properties enable a class to expose a public way of getting and setting values, while
hiding implementation code.
• JavaFX properties are observable, which means every time they are changed, the
view is notified.
• When creating new properties, one should use the SimplexxxxxxxProperty as it is an
implementation of the Observable, ReadOnlyxxxxxxProperty and the
xxxxxxxProperty.
find more resources at oneclass.com
find more resources at oneclass.com