|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--java.awt.Component
|
+--java.awt.Container
|
+--javax.swing.JComponent
|
+--javax.swing.JPanel
|
+--edu.neu.ccs.gui.DisplayPanel
A is a
Displayable that recursively propagates
JPanelDisplayable method calls
only to contained components
that are also Displayable.
This class is the base class for all panel-style containers provided by the JPT.
As of the 2.3.3, methods have been provided that permit a
DisplayPanel to self-actualize, that is,
to install inself in a window and open that window.
The various frame methods install this panel into a
JPTFrame which is an extension of the Java class
JFrame.
The various methods that have dialog in their name
install this panel into a GeneralDialog which is
an extension of the Java class JDialog.
Since no component should be installed in more than one frame or dialog, the user should take care to call at most one of the above methods and do this at most once while an object is alive. To support this rule and to ensure that the panel is installed in a window at construction, we recommend the following convention.
Convention: If you choose to call a frame or dialog method, do this either as the last line in a constructor or soon after the constructor returns.
Since the methods that install a DisplayPanel
in a frame or dialog return that window, the caller may save
the window reference and later close and reopen the window if
desired.
Displayable,
Serialized Form| Field Summary | |
protected Color |
background
Background color before alert status was entered. |
protected String |
codec
Identifier for codec used by this panel. |
static String |
CODEC
Bound property name for the codec property. |
| Fields inherited from class javax.swing.JComponent |
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
| Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface edu.neu.ccs.gui.Displayable |
DEFAULT_VIEW_STATE, VIEW_STATE |
| Fields inherited from interface edu.neu.ccs.util.JPTConstants |
ABOVE, ALIGNMENT, BELOW, BOTTOM_LEFT, BOTTOM_RIGHT, DEFAULT, FONT, INPUT_PROPERTIES, MANDATORY, OPTIONAL, ORIENTATION, TOP_LEFT, TOP_RIGHT |
| Fields inherited from interface javax.swing.SwingConstants |
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
| Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
DisplayPanel()
Constructs a panel with the default layout manager for a . |
|
DisplayPanel(boolean isDoubleBuffered)
Constructs a panel with the default layout manager for a
and the given double-buffering strategy. |
|
DisplayPanel(LayoutManager layout)
Constructs a panel with the given layout manager. |
|
DisplayPanel(LayoutManager layout,
boolean isDoubleBuffered)
Constructs a panel with the given layout manager and the given double-buffering strategy. |
|
| Method Summary | |
Component |
add(Component c)
Adds the specified component to the end of this container. |
Component |
add(Component c,
int index)
Adds the specified component to this container at the given position. |
void |
add(Component c,
Object constraints)
Adds the specified component to the end of this container. |
void |
add(Component c,
Object constraints,
int index)
Adds the specified component at the given position. |
Component |
add(String name,
Component c)
Adds the given component to this container. |
Component |
addObject(Object object)
Add the given object to this DisplayPanel
at the next available position
after applying the transformation of the method
makeComponent. |
Component |
addObject(Object object,
int index)
Add the given object to this DisplayPanel
at the given index position
after applying the transformation of the method
makeComponent. |
Component |
addObject(Object object,
Object constraints)
Add the given object to this DisplayPanel
with the specified constaints
at the next appropriate position
after applying the transformation of the method
makeComponent. |
Component |
addObject(Object object,
Object constraints,
int index)
Add the given object to this DisplayPanel
at the given index position
after applying the transformation of the method
makeComponent. |
void |
dataMalformed(MalformedDataEvent evt)
Handles a malformed data event generated by a fragile input component by alerting the user through a change to the background color of the panel. |
void |
endAlert(AlertEvent evt)
Turns off alert status for this component and its children that are also AlertListeners. |
JPTFrame |
frame()
Frame this panel in a JPTFrame and open the frame; return the frame constructed. |
JPTFrame |
frame(int location)
Frame this panel in a JPTFrame and open the frame; use the given location which should be either CENTER or one of the standard constants
for one of the eight compass directions;
return the frame constructed. |
JPTFrame |
frame(String title)
Frame this panel in a JPTFrame and open the frame; use the given title for the frame; return the frame constructed. |
JPTFrame |
frame(String title,
Insets insets)
Frame this panel in a JPTFrame and open the frame; use the given title for the frame; use the given insets to inset the frame in the screen; return the frame constructed. |
JPTFrame |
frame(String title,
int location)
Frame this panel in a JPTFrame and open the frame; use the given title for the frame; use the given location which should be either CENTER or one of the standard constants
for one of the eight compass directions;
return the frame constructed. |
JPTFrame |
frame(String title,
int location,
Insets insets)
Frame this panel in a JPTFrame and open the frame; use the given title for the frame; use the given location which should be either CENTER or one of the standard constants
for one of the eight compass directions;
use the given insets to inset the frame in the screen;
return the frame constructed. |
GeneralDialog |
generalDialog(Object[][] actionData)
Place this panel in a modal general dialog and open the dialog; use the action data to define the dialog buttons; return the dialog constructed. |
GeneralDialog |
generalDialog(Object[][] actionData,
Object defaultAction)
Place this panel in a modal general dialog and open the dialog; use the action data to define the dialog buttons; use the default action object to define the default button; return the dialog constructed. |
GeneralDialog |
generalDialog(String title,
Object[][] actionData)
Place this panel in a modal general dialog and open the dialog; use the given title for the dialog; use the action data to define the dialog buttons; return the dialog constructed. |
GeneralDialog |
generalDialog(String title,
Object[][] actionData,
Object defaultAction)
Place this panel in a modal general dialog and open the dialog; use the given title for the dialog; use the action data to define the dialog buttons; use the default action object to define the default button; return the dialog constructed. |
String |
getCodec()
Returns the identifier for the current CODEC to be used to combine multiple child view states into an encoded String. |
String |
getDefaultViewState()
Returns the default view states for objects in the collection as an encoded String. |
String |
getViewState()
Returns the view states for objects in the container as an encoded String. |
Component |
makeComponent(Object o)
By default, this method will return the Component constructed using
ComponentFactory.makeComponent. |
GeneralDialog |
OKCancelDialog()
Place this panel in a modal OK-Cancel dialog and open the dialog; return the dialog constructed. |
GeneralDialog |
OKCancelDialog(String title)
Place this panel in a modal OK-Cancel dialog and open the dialog; use the given title for the dialog; return the dialog constructed. |
GeneralDialog |
OKDialog()
Place this panel in a modal OK dialog and open the dialog; return the dialog constructed. |
GeneralDialog |
OKDialog(String title)
Place this panel in a modal OK dialog and open the dialog; use the given title for the dialog; return the dialog constructed. |
void |
refreshComponent()
Refreshes the component by repacking the parent window. |
void |
remove(Component c)
Removes the given component from this container. |
void |
remove(int index)
Removes the component at the given index from this container. |
void |
removeAll()
Removes all of the components from this container. |
void |
reset()
Recursively resets any Displayable objects
held in the panel. |
void |
setCodec(String codecID)
Sets the identifier for the CODEC to be used to combine multiple child view states into an encoded String. |
void |
setDefaultViewState(String data)
Sets the default view states for objects in the collection to the data encoded in the given String. |
void |
setEnabled(boolean isEnabled)
Enables or disables the panel, and recursively enables or disables its contents, based on the given value. |
void |
setViewState(String data)
Sets the view states for Displayable objects in the container
to the data encoded in the given String. |
void |
startAlert(AlertEvent evt)
Turns on alert status for this component and its children that are also AlertListeners. |
void |
uniformizeHeight()
Sets the preferred height for all JComponents
in this panel to the same height. |
void |
uniformizeSize()
Sets the preferred size for all JComponents
in this panel to the same preferred size. |
void |
uniformizeWidth()
Sets the preferred width for all JComponents
in this panel to the same width. |
GeneralDialog |
YesNoCancelDialog()
Place this panel in a modal Yes-No-Cancel dialog and open the dialog; return the dialog constructed. |
GeneralDialog |
YesNoCancelDialog(String title)
Place this panel in a modal Yes-No-Cancel dialog and open the dialog; use the given title for the dialog; return the dialog constructed. |
| Methods inherited from class javax.swing.JPanel |
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final String CODEC
protected Color background
protected String codec
| Constructor Detail |
public DisplayPanel()
JPanel.
public DisplayPanel(boolean isDoubleBuffered)
JPanel
and the given double-buffering strategy.
isDoubleBuffered - whether or not the panel
makes use of double-bufferingpublic DisplayPanel(LayoutManager layout)
layout - the desired layout manager
public DisplayPanel(LayoutManager layout,
boolean isDoubleBuffered)
layout - the desired layout managerisDoubleBuffered - whether or not the panel
makes use of double-buffering| Method Detail |
public void setViewState(String data)
Sets the view states for
Displayable objects in the container
to the data encoded in the given String.
If the given encoded data is null,
the view states are not changed.
null,
the data is decoded into its component data elements
and the view state for each of as many
Displayable objects as possible
is set to the state encapsulated in the corresponding
data element.
If the encoded data contains more data elements
than there are Displayable objects in the panel,
the extraneous data elements are ignored.
If the encoded data contains fewer data elements
than there are Displayable objects in the panel,
the view states are not changed for objects that
do not have a corresponding data element.
setViewState in interface Displayabledata - the encoded String datagetViewState(),
Displayablepublic String getViewState()
String.
The encoded data is constructed by collecting an array
containing the view states for each of the
Displayable objects in the container
and encoding it using the CODEC whose identifier
is stored by this panel.
getViewState in interface DisplayableStringsetViewState(String),
Displayablepublic void setDefaultViewState(String data)
String.
If the given encoded data is null,
the default view states are not changed.
null,
the data is decoded into its component data elements
and the default view state for each of as many
Displayable objects as possible
is set to the state encapsulated in the corresponding
data element.
If the encoded data contains more data elements
than there are Displayable objects in the panel,
the extraneous data elements are ignored.
If the encoded data contains fewer data elements
than there are Displayable objects in the panel,
the default view states are not changed for objects that
do not have a corresponding data element.
setDefaultViewState in interface Displayabledata - the desired default String datareset(),
Displayablepublic String getDefaultViewState()
String.
The encoded data is constructed by collecting an array
containing the default view states for each of the
Displayable objects in the container
and encoding it using the CODEC whose identifier
is stored by this panel.
getDefaultViewState in interface DisplayableStringsetDefaultViewState(String),
reset()public void setEnabled(boolean isEnabled)
setEnabled in interface DisplayablesetEnabled in class JComponentisEnabled - whether or not this panel is to be enabledDisplayablepublic void reset()
Displayable objects
held in the panel.
reset in interface DisplayablesetDefaultViewState(String),
Displayablepublic void dataMalformed(MalformedDataEvent evt)
dataMalformed in interface MalformedDataListenerevt - the malformed data eventMalformedDataListenerpublic void startAlert(AlertEvent evt)
AlertListeners.
startAlert in interface AlertListenerevt - the alert eventAlertListenerpublic void endAlert(AlertEvent evt)
AlertListeners.
endAlert in interface AlertListenerevt - the alert eventAlertListenerpublic Component add(Component c)
add in class Containerc - the component to be added
add(Component, int),
add(Component, Object),
add(Component, Object, int),
add(String, Component),
remove(Component),
remove(int),
removeAll()
public Component add(Component c,
int index)
add in class Containerc - the component to be addedindex - the position at which to insert the component,
or -1 to insert the component at the end.
add(Component),
add(Component, Object),
add(Component, Object, int),
add(String, Component),
remove(Component),
remove(int),
removeAll()
public void add(Component c,
Object constraints)
add in class Containerc - the component to be addedconstraints - an object expressing layout constraints
for this componentadd(Component),
add(Component, int),
add(Component, Object, int),
add(String, Component),
remove(Component),
remove(int),
removeAll()
public void add(Component c,
Object constraints,
int index)
add in class Containerc - the component to be addedconstraints - an object expressing layout constraints
for this componentindex - the position at which to insert the component,
or -1 to insert the component at the end.add(Component),
add(Component, int),
add(Component, Object),
add(String, Component),
remove(Component),
remove(int),
removeAll()
public Component add(String name,
Component c)
add(Component, Object),
in place of this method.
add in class Containername - the name of the component to be addedc - the component to be added
add(Component),
add(Component, int),
add(Component, Object),
add(Component, Object, int),
remove(Component),
remove(int),
removeAll()public Component addObject(Object object)
DisplayPanel
at the next available position
after applying the transformation of the method
makeComponent.
object - the object to be transformed and added to the panel
addObject(Object, int),
addObject(Object, Object),
addObject(Object, Object, int),
makeComponent(Object)
public Component addObject(Object object,
int index)
DisplayPanel
at the given index position
after applying the transformation of the method
makeComponent.
object - the object to be transformed and added to the panelindex - the position at which to add the component
addObject(Object),
addObject(Object, Object),
addObject(Object, Object, int),
makeComponent(Object)
public Component addObject(Object object,
Object constraints)
DisplayPanel
with the specified constaints
at the next appropriate position
after applying the transformation of the method
makeComponent.
object - the object to be transformed and added to the panelconstraints - an object expressing layout constraints for the component
addObject(Object),
addObject(Object, int),
addObject(Object, Object, int),
makeComponent(Object)
public Component addObject(Object object,
Object constraints,
int index)
DisplayPanel
at the given index position
after applying the transformation of the method
makeComponent.
object - the object to be transformed and added to the panelconstraints - an object expressing layout constraints for the componentindex - the position at which to add the component
addObject(Object),
addObject(Object, int),
addObject(Object, Object),
makeComponent(Object)public Component makeComponent(Object o)
Component constructed using
ComponentFactory.makeComponent.
ComponentFactory.makeComponent(Object)public void remove(Component c)
remove in class Containerc - the component to be removedadd(Component),
add(Component, int),
add(Component, Object),
add(Component, Object, int),
add(String, Component),
remove(int),
removeAll()public void remove(int index)
remove in class Containerindex - the index of the component to be removedadd(Component),
add(Component, int),
add(Component, Object),
add(Component, Object, int),
add(String, Component),
remove(Component),
removeAll()public void removeAll()
removeAll in class Containeradd(Component),
add(Component, int),
add(Component, Object),
add(Component, Object, int),
add(String, Component),
remove(Component),
remove(int)public void uniformizeSize()
Sets the preferred size for all JComponents
in this panel to the same preferred size.
The preferred size that is used is created from the widest preferred width and tallest preferred height among the contained components.
public void uniformizeWidth()
Sets the preferred width for all JComponents
in this panel to the same width.
The preferred width that is used is created from the widest preferred width among the contained components.
public void uniformizeHeight()
Sets the preferred height for all JComponents
in this panel to the same height.
The preferred height that is used is created from the tallest preferred height among the contained components.
public void setCodec(String codecID)
String.
If the given identifier is null,
the CODEC is not changed.
codecID - identifier of the codec to be usedgetCodec()public String getCodec()
String.
setCodec(String)public JPTFrame frame()
Frame this panel in a JPTFrame and open the frame; return the frame constructed.
public JPTFrame frame(int location)
Frame this panel in a JPTFrame
and open the frame;
use the given location which should be either
CENTER or one of the standard constants
for one of the eight compass directions;
return the frame constructed.
location - the constant representing the frame location
public JPTFrame frame(String title)
Frame this panel in a JPTFrame and open the frame; use the given title for the frame; return the frame constructed.
title - the title for the frame
public JPTFrame frame(String title,
int location)
Frame this panel in a JPTFrame
and open the frame;
use the given title for the frame;
use the given location which should be either
CENTER or one of the standard constants
for one of the eight compass directions;
return the frame constructed.
title - the title for the framelocation - the constant representing the frame location
public JPTFrame frame(String title,
Insets insets)
Frame this panel in a JPTFrame and open the frame; use the given title for the frame; use the given insets to inset the frame in the screen; return the frame constructed.
title - the title for the frameinsets - the screen insets to use to adjust the location
public JPTFrame frame(String title,
int location,
Insets insets)
Frame this panel in a JPTFrame
and open the frame;
use the given title for the frame;
use the given location which should be either
CENTER or one of the standard constants
for one of the eight compass directions;
use the given insets to inset the frame in the screen;
return the frame constructed.
title - the title for the framelocation - the constant representing the frame locationinsets - the screen insets to use to adjust the location
public GeneralDialog OKDialog()
Place this panel in a modal OK dialog and open the dialog; return the dialog constructed.
public GeneralDialog OKDialog(String title)
Place this panel in a modal OK dialog and open the dialog; use the given title for the dialog; return the dialog constructed.
title - the title for the dialog
public GeneralDialog OKCancelDialog()
Place this panel in a modal OK-Cancel dialog and open the dialog; return the dialog constructed.
public GeneralDialog OKCancelDialog(String title)
Place this panel in a modal OK-Cancel dialog and open the dialog; use the given title for the dialog; return the dialog constructed.
title - the title for the dialog
public GeneralDialog YesNoCancelDialog()
Place this panel in a modal Yes-No-Cancel dialog and open the dialog; return the dialog constructed.
public GeneralDialog YesNoCancelDialog(String title)
Place this panel in a modal Yes-No-Cancel dialog and open the dialog; use the given title for the dialog; return the dialog constructed.
title - the title for the dialog
public GeneralDialog generalDialog(Object[][] actionData)
Place this panel in a modal general dialog and open the dialog; use the action data to define the dialog buttons; return the dialog constructed.
The parameter actionData
is an Object[][] array that specifies
each dialog Action in one of the following ways:
ActionIf the option parameter is specified, it must be one of the following values that will determine what is done to the dialog when the action is finished:
- DialogAction.KEEP_OPEN
- DialogAction.AUTO_CLOSE
- DialogAction.SET_CANCEL
If the option parameter is not specified, it is taken to be
DialogAction.AUTO_CLOSE.
actionData - the action data
public GeneralDialog generalDialog(Object[][] actionData,
Object defaultAction)
Place this panel in a modal general dialog and open the dialog; use the action data to define the dialog buttons; use the default action object to define the default button; return the dialog constructed.
The parameter actionData
is an Object[][] array that specifies
each dialog Action in one of the following ways:
ActionIf the option parameter is specified, it must be one of the following values that will determine what is done to the dialog when the action is finished:
- DialogAction.KEEP_OPEN
- DialogAction.AUTO_CLOSE
- DialogAction.SET_CANCEL
If the option parameter is not specified, it is taken to be
DialogAction.AUTO_CLOSE.
The Object supplied for the default action must either be
an Action or a name that is supplied in the action data. If
the parameter is null, no default action is set.
actionData - the action datadefaultAction - the default action
public GeneralDialog generalDialog(String title,
Object[][] actionData)
Place this panel in a modal general dialog and open the dialog; use the given title for the dialog; use the action data to define the dialog buttons; return the dialog constructed.
The parameter actionData
is an Object[][] array that specifies
each dialog Action in one of the following ways:
ActionIf the option parameter is specified, it must be one of the following values that will determine what is done to the dialog when the action is finished:
- DialogAction.KEEP_OPEN
- DialogAction.AUTO_CLOSE
- DialogAction.SET_CANCEL
If the option parameter is not specified, it is taken to be
DialogAction.AUTO_CLOSE.
title - the title for the dialogactionData - the action data
public GeneralDialog generalDialog(String title,
Object[][] actionData,
Object defaultAction)
Place this panel in a modal general dialog and open the dialog; use the given title for the dialog; use the action data to define the dialog buttons; use the default action object to define the default button; return the dialog constructed.
The parameter actionData
is an Object[][] array that specifies
each dialog Action in one of the following ways:
ActionIf the option parameter is specified, it must be one of the following values that will determine what is done to the dialog when the action is finished:
- DialogAction.KEEP_OPEN
- DialogAction.AUTO_CLOSE
- DialogAction.SET_CANCEL
If the option parameter is not specified, it is taken to be
DialogAction.AUTO_CLOSE.
The Object supplied for the default action must either be
an Action or a name that is supplied in the action data. If
the parameter is null, no default action is set.
title - the title for the dialogactionData - the action datadefaultAction - the default action
public void refreshComponent()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||