Class View

  • All Implemented Interfaces:
    Styleable, EventTarget
    Direct Known Subclasses:

    public class View
    extends BorderPane

    View is a layout container that closely matches the typical layout of many mobile application. All user interfaces are built using views. Each view has a unique name and it needs to be passed to construct a View instance.

    Layers can be placed on top of a View by calling By doing this, it is possible to present popup cards and other context-specific information to users.

    Developers create and add Views to an application using the AppManager class. For this the method AppManager.addViewFactory(String, Supplier) is called passing in the name of the View, which must be unique, and a View factory which when called by Glisten, should return a new instance of this particular View. The most important view factory is the one that specifies the 'home view', which is shown when the application first starts. For example, the following sample is an application with a single View that has the Label with the text 'Hello World' as its contents:

     public class HelloWorld extends MobileApplication {
       public void init() {
         addViewFactory(HOME_VIEW, () -> {
           Label helloWorld = new Label("Hello world!");
           return new View(helloWorld) {
             protected void updateAppBar(AppBar appBar) {
               appBar.setTitleText("Some title");

    Screenshot of a View

    From the user interacting with a View a change to another View might be desirable. To do this, developers should call AppManager.switchView(String) or a similar method.

    Views can update the contents of the AppBar by overriding updateAppBar(AppBar). In order to hide an AppBar from a View, Node.visibleProperty() should be set to false.

    For more information about Views and how they fit into the overall Glisten framework checkout the API documentation of the AppManager class.

    See Also:
    AppManager, Layer