|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jdesktop.application.AbstractBean
org.jdesktop.application.View
public class View
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.
JRootPane
,
Application.show(View)
,
Application.hide(View)
Constructor Summary | |
---|---|
View(Application application)
Construct an empty View object for the specified Application. |
Method Summary | |
---|---|
Application |
getApplication()
The Application that's responsible for showing/hiding this View. |
javax.swing.JComponent |
getComponent()
The main {JComponent} for this View. |
ApplicationContext |
getContext()
The ApplicationContext for the Application that's responsible for showing/hiding this View. |
javax.swing.JMenuBar |
getMenuBar()
The main {JMenuBar} for this View. |
ResourceMap |
getResourceMap()
The ResourceMap for this View. |
javax.swing.JRootPane |
getRootPane()
The JRootPane for this View. |
javax.swing.JComponent |
getStatusBar()
|
javax.swing.JToolBar |
getToolBar()
|
java.util.List<javax.swing.JToolBar> |
getToolBars()
|
void |
setComponent(javax.swing.JComponent component)
Set the single main Component for this View. |
void |
setMenuBar(javax.swing.JMenuBar menuBar)
|
void |
setStatusBar(javax.swing.JComponent statusBar)
|
void |
setToolBar(javax.swing.JToolBar toolBar)
|
void |
setToolBars(java.util.List<javax.swing.JToolBar> toolBars)
|
Methods inherited from class org.jdesktop.application.AbstractBean |
---|
addPropertyChangeListener, addPropertyChangeListener, firePropertyChange, firePropertyChange, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public View(Application application)
application
- the Application responsible for showing/hiding this ViewApplication.show(View)
,
Application.hide(View)
Method Detail |
---|
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 is just shorthand for getContext().getResourceMap(getClass(), View.class)
.
ResourceMap
for this ViewgetContext()
public javax.swing.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 javax.swing.JComponent getComponent()
component
for this ViewsetComponent(javax.swing.JComponent)
public void setComponent(javax.swing.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 javax.swing.JMenuBar getMenuBar()
menuBar
for this ViewsetMenuBar(javax.swing.JMenuBar)
public void setMenuBar(javax.swing.JMenuBar menuBar)
public java.util.List<javax.swing.JToolBar> getToolBars()
public void setToolBars(java.util.List<javax.swing.JToolBar> toolBars)
public final javax.swing.JToolBar getToolBar()
public final void setToolBar(javax.swing.JToolBar toolBar)
public javax.swing.JComponent getStatusBar()
public void setStatusBar(javax.swing.JComponent statusBar)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |