public class View extends AbstractBean
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.
JRootPane,
Application.show(View),
Application.hide(View)| Constructor and Description |
|---|
View(Application application)
Construct an empty View object for the specified Application.
|
| Modifier and Type | Method and Description |
|---|---|
Application |
getApplication()
Returns the
Application that's responsible for showing/hiding this View. |
JComponent |
getComponent()
Returns the main
JComponent for this View. |
ApplicationContext |
getContext()
Gets the
ApplicationContext for the Application that's responsible for showing/hiding this View. |
JMenuBar |
getMenuBar()
Returns the main
JMenuBar for this View. |
ResourceMap |
getResourceMap()
Gets
ResourceMap for this View. |
JRootPane |
getRootPane()
Gets the
JRootPane for this View. |
JComponent |
getStatusBar()
Returns the Status bar for this View.
|
JToolBar |
getToolBar()
Gets the first tool bar for this View
|
List<JToolBar> |
getToolBars()
Returns the list of tool bars for this View
|
void |
setComponent(JComponent component)
Sets the single main Component for this View.
|
void |
setMenuBar(JMenuBar menuBar)
Sets the menu bar for this View.
|
void |
setStatusBar(JComponent statusBar)
Sets the status bar for this View.
|
void |
setToolBar(JToolBar toolBar)
Sets the only tool bar for this View.
|
void |
setToolBars(List<JToolBar> toolBars)
Sets the tool bars for this View
|
addPropertyChangeListener, addPropertyChangeListener, firePropertyChange, firePropertyChange, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListenerpublic View(Application application)
application - the Application responsible for showing/hiding this ViewApplication.show(View),
Application.hide(View)public final Application getApplication()
Application that's responsible for showing/hiding this View.getContext(),
Application.show(View),
Application.hide(View)public final ApplicationContext getContext()
ApplicationContext for the Application that's responsible for showing/hiding this View.
This method is just shorthand for getApplication().getContext().getApplication(),
Application.show(View),
Application.hide(View)public ResourceMap getResourceMap()
ResourceMap for this View.
This method invokes getContext().getResourceMap(getClass(), View.class).
The result is cached.ResourceMap for this ViewgetContext()public JRootPane getRootPane()
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.rootPane for this ViewsetComponent(javax.swing.JComponent),
setMenuBar(javax.swing.JMenuBar),
setToolBar(javax.swing.JToolBar),
setStatusBar(javax.swing.JComponent)public JComponent getComponent()
JComponent for this View.component for this ViewsetComponent(javax.swing.JComponent)public void setComponent(JComponent component)
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.
component - The component for this ViewgetComponent()public JMenuBar getMenuBar()
JMenuBar for this View.menuBar for this ViewsetMenuBar(javax.swing.JMenuBar)public void setMenuBar(JMenuBar menuBar)
This is a bound property. The default value is null.
menuBar - The menuBar for this ViewgetMenuBar()public List<JToolBar> getToolBars()
public void setToolBars(List<JToolBar> toolBars)
This is a bound property. The default value is an empty list.
toolBars - setToolBar(JToolBar),
getToolBars()public final JToolBar getToolBar()
JToolBar for this ViewsetToolBars(java.util.List<javax.swing.JToolBar>),
getToolBars(),
setToolBar(javax.swing.JToolBar)public final void setToolBar(JToolBar toolBar)
This is a bound property.
toolBar - The JToolBar for this view. If null resets the tool bar.getToolBar(),
setToolBars(List),
getToolBars()public JComponent getStatusBar()
JComponent for this Viewpublic void setStatusBar(JComponent statusBar)
JComponent.statusBar - The status bar JComponent for this ViewCopyright © 2009–2016. All rights reserved.