48024 Lecture Notes - Lecture 10: Scene Graph

50 views2 pages
5 Jun 2018
School
Department
Course
Professor
Study 10 - GUI Lists
Packages
A package is a collection of related classes.
Each application or library should be placed in its own package.
Complex applications are often further divided into sub-packages being the model,
the view and the controller.
Classes are declared into packages with a package declaration at the top of the
douet, ith the path ae of the pakage proeedig pakage
ListView
A ListView<X> displays a list of items of type X.
Items in the list can be wither Strings or objects with a toString() function.
They can be created in FXML or Java.
o <ListVie fx:id=aoutsL/>
o ListView<Account> accountsLv = new ListView<Account>();
They support two selection models, being single or multiple selection. In both
models, clicking an item selects the item and the previously selected item will
become deselected.
In a multiple selection model, shift-click or control-click will select multiple items.
A placeholder can be used to display something when the ListView is empty
o <ListView><placeholder><Lael text=No Aouts/></ plaeholder></ListVie>
o aoutsL.setPlaeholdere LaelNo Aouts;
To link a ListView to the model, use an ObservableList, where observers are notified
whenever the list contents changes. To do this, define the observable list as an
immutable property with mutable state, and then bind the items property of
ListView to the desired property within the model.
The selected item can be accessed through the selection model:
o accountsLv.getSelectionModel().getSelectedItem();
Opening a Window
To open a new window, you need to load the view from FXML, link the controller to
the appropriate odel, ad reate a e “tage, hih ill sho the ie’s see
graph on the page.
UTS provides a package to help with this, which has a ViewLoader method:
o ViewLoader.showStage(<model>,<fxml>,<title>,<stage>);
In this package, there is also a controller class which inherits the model and stage
fields of the extended class. This way allows the model to be returned through the
getter in less code, as it is now an inherited field:
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows half of the first page of the document.
Unlock all 2 pages and 3 million more documents.

Already have an account? Log in

Document Summary

Items in the list can be wither strings or objects with a tostring() function: a listview displays a list of items of type x, they can be created in fxml or java, Listview accountslv = new listview(): they support two selection models, being single or multiple selection. In both models, clicking an item selects the item and the previously selected item will become deselected. To do this, define the observable list as an immutable property with mutable state, and then bind the items property of. Listview to the desired property within the model: the selected item can be accessed through the selection model, accountslv. getselectionmodel(). getselecteditem(); In this package, there is also a controller class which inherits the model and stage fields of the extended class. This way allows the model to be returned through the getter in less code, as it is now an inherited field:

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents