|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface PanelInterface
Defines a common set of functionality that a panel should surface to be hosted in an application.
Instead of writing a panel, a developer often writes a tabbed pane or dialog that
contains the definitions of the components that are contained within. Then
later it is determined that those components have use elsewhere in an application.
To solve this problem those components must be abstracted out or the source code must be cloned.
If those components were originally abstracted out into a single reusable component
(i.e. panel) it would be simple to reuse the panel
wherever it is needed. The problem with this approach is that there is not a common
way to do this. Each application would determine what the definition of a "common" panel is.
PanelInterface
solves this problem by defining the required
functionality for a panel to be embedded in some container and to be correctly notified
of the lifetime of that panel (when to apply changes, when to hide it, etc).
Sometimes panels simply convey information (i.e. properties), however, they often provide some editing capabilities. Therefore, then need to know when to apply or cancel any changes that have been during that panel's lifetime. The following methods provides a means of determining certain events that can occur on a panel:
Often panels are embedded in tabbed panes or dialogs. The user then must decide on a title for the tab or dialog that the panel is embedded in. The panel can provide the title itself through the following methods:
Some panels want to provide context-sensitive help (i.e. via a help button on a hosting dialog). The following method provides a means of doing this:
If a panel is going to live primarily in a dialog, it may be important for that panel to control
whether or not any changes can be applied based on the state of its contents. If the panel
considers its contents invalid it may want to disable the "ok" and "apply" buttons in the hosting
dialog. PanelInterface
solves this with the contentsValid
property. A PanelInterface
-aware dialog can listen for this property such that when it
receives notification that it has changed, the dialog can update its buttons accordingly. Likewise,
an implementation of PanelInterface
should fire a PropertyChangeEvent
for the contentsValid
property whenever the state changes.
Field Summary | |
---|---|
static java.lang.String |
CONTENTS_VALID_PROPERTY
Property identifier for the "contentsValid" property. |
Method Summary | |
---|---|
java.lang.String |
getDialogTitle()
Returns a title for this panel that should be displayed on a dialog's title bar. |
java.lang.String |
getHelpID()
Returns the help id for this panel. |
javax.swing.JComponent |
getPanel()
Returns the panel to be displayed. |
java.lang.String |
getTabTitle()
Returns a title for this panel that should be displayed as a title on a tab. |
boolean |
isContentsValid()
Indicates if the panel's contents are in a valid state. |
boolean |
isYesNo()
Indicates if the panel asks a yes-no or ok type question. |
void |
onApply()
Apply any changes that may have been made in the panel. |
void |
onCancel()
Cancel any changes that may have been made in the panel. |
void |
onClose()
Indicates that the panel is being closed. |
void |
setContentsValid(boolean newValue)
Sets the valid state of the panel's contents. |
Field Detail |
---|
static final java.lang.String CONTENTS_VALID_PROPERTY
isContentsValid()
,
setContentsValid(boolean)
,
Constant Field ValuesMethod Detail |
---|
void onApply()
void onCancel()
void onClose()
onApply()
or onClose()
is called.
java.lang.String getDialogTitle()
java.lang.String getTabTitle()
javax.swing.JComponent getPanel()
this
.
java.lang.String getHelpID()
null
is returned, a help button is
not added for this panel.
boolean isYesNo()
true
if the panel asks a yes-no type question,
false
if the panel asks an ok type questionboolean isContentsValid()
true
except for when the panel is behaving as an editor and incomplete information has been entered.
This state can be used by a dialog, for example, to enable/disable the its "apply" buttons ("OK", "Yes", etc).
true
if the panel's contents are valid, otherwise false
setContentsValid(boolean)
void setContentsValid(boolean newValue)
PanelInterface
provides the property name identifier CONTENTS_VALID_PROPERTY
as
a convenience for implementing this as a bound property.
newValue
- the new valid state for the panel's contentsisContentsValid()
|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |