Class View

Direct Known Subclasses:
FrameView

public class View extends AbstractBean
A View encapsulates a top-level Application GUI component, like a JFrame or an Applet, and its main GUI elements: a menu bar, tool bar, component, and a status bar. All of the elements are optional (although a View without a main component would be unusual). Views have a JRootPane, which is the root component for all of the Swing Window types as well as JApplet. Setting a View property, like menuBar or toolBar, just adds a component to the rootPane in a way that's defined by the View subclass. By default the View elements are arranged in a conventional way:
  • menuBar - becomes the rootPane's JMenuBar
  • toolBar - added to BorderLayout.NORTH of the rootPane's contentPane
  • component - added to BorderLayout.CENTER of the rootPane's contentPane
  • statusBar - added to BorderLayout.SOUTH of the rootPane's contentPane

To show or hide a View you call the corresponding Application methods. Here's a simple example:

class MyApplication extends SingleFrameApplication {
    @ppOverride protected void startup() {
        View view = getMainView();
        view.setComponent(createMainComponent());
        view.setMenuBar(createMenuBar());
        show(view);
    }
}

The advantage of Views over just configuring a JFrame or JApplet directly, is that a View is more easily moved to an alternative top level container, like a docking framework.

See Also:
  • Constructor Details

  • Method Details

    • getApplication

      public final Application getApplication()
      The Application that's responsible for showing/hiding this View.
      Returns:
      the Application that owns this View
      See Also:
    • getContext

      public final ApplicationContext getContext()
      The ApplicationContext for the Application that's responsible for showing/hiding this View. This method is just shorthand for getApplication().getContext().
      Returns:
      the Application that owns this View
      See Also:
    • getResourceMap

      public ResourceMap getResourceMap()
      The ResourceMap for this View. This method is just shorthand for getContext().getResourceMap(getClass(), View.class).
      Returns:
      The ResourceMap for this View
      See Also:
    • getRootPane

      public JRootPane getRootPane()
      The JRootPane for this View. All of the components for this View must be added to its rootPane. Most applications will do so by setting the View's component, menuBar, toolBar, and statusBar properties.
      Returns:
      The rootPane for this View
      See Also:
    • getComponent

      public JComponent getComponent()
      The main {JComponent} for this View.
      Returns:
      The component for this View
      See Also:
    • setComponent

      public void setComponent(JComponent component)
      Set the single main Component for this View. It's added to the BorderLayout.CENTER of the rootPane's contentPane. If the component property was already set, the old component is removed first.

      This is a bound property. The default value is null.

      Parameters:
      component - The component for this View
      See Also:
    • getMenuBar

      public JMenuBar getMenuBar()
      The main {JMenuBar} for this View.
      Returns:
      The menuBar for this View
      See Also:
    • setMenuBar

      public void setMenuBar(JMenuBar menuBar)
    • getToolBars

      public List<JToolBar> getToolBars()
    • setToolBars

      public void setToolBars(List<JToolBar> toolBars)
    • getToolBar

      public final JToolBar getToolBar()
    • setToolBar

      public final void setToolBar(JToolBar toolBar)
    • getStatusBar

      public JComponent getStatusBar()
    • setStatusBar

      public void setStatusBar(JComponent statusBar)