edu.neu.ccs.gui
Class DisplayPanel

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended byedu.neu.ccs.gui.DisplayPanel
All Implemented Interfaces:
Accessible, AlertListener, Displayable, EventListener, ImageObserver, JPTConstants, MalformedDataListener, MenuContainer, Serializable, SwingConstants
Direct Known Subclasses:
ActionsPanel, Annotation, ArrayPanel, BasePane, BufferedPanel, BufferedPanel.Painter, ColorView, Display, DisplayCollection, FileView, FontSampler, Halo, ImageViewerBase, JPFPane, MethodGUI, RequestImageViewer, RequestWebImageViewer, SimpleFunctionBuilder, SimpleFunctionBuilderWithIO, StringViewer, TablePanel, VisualColorList, VisualColorSampler, ZooContainer

public class DisplayPanel
extends JPanel
implements Displayable, MalformedDataListener, JPTConstants

A DisplayPanel is a JPanel that recursively propagates Displayable 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.

As of 2.4.0, the class allows a caller to obtain an array of all Displayables installed in the panel.

As of 2.5.0, convenience methods were added to add borders based on the methods in class Borders.

Since:
1.0
Version:
2.5.0
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
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.JPanel
 
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.Container
 
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, VALUE
 
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 JPanel.
DisplayPanel(boolean isDoubleBuffered)
          Constructs a panel with the default layout manager for a JPanel 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.
 Border addBorder(Border border)
          Adds the given border as an outer wrapper around the current border of the component.
 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 bevelBorderLowered()
          Adds a default lowered bevel border.
 void bevelBorderLowered(Color highlight, Color shadow)
          Adds a lowered bevel border with the given highlight and shadow colors.
 void bevelBorderLowered(Color highlightOuter, Color highlightInner, Color shadowInner, Color shadowOuter)
          Adds a lowered bevel border with the given colors.
 void bevelBorderLowered(int levels, Color highlight, Color shadow)
          Adds a lowered bevel border with the given parameters.
 void bevelBorderLowered(int levels, Color highlightOuter, Color highlightInner, Color shadowInner, Color shadowOuter)
          Adds a lowered bevel border with the given parameters.
 void bevelBorderRaised()
          Adds a raised bevel border.
 void bevelBorderRaised(Color highlight, Color shadow)
          Adds a raised bevel border with the given highlight and shadow colors.
 void bevelBorderRaised(Color highlightOuter, Color highlightInner, Color shadowInner, Color shadowOuter)
          Adds a raised bevel border with the given colors.
 void bevelBorderRaised(int levels, Color highlight, Color shadow)
          Adds a raised bevel border with the given parameters.
 void bevelBorderRaised(int levels, Color highlightOuter, Color highlightInner, Color shadowInner, Color shadowOuter)
          Adds a raised bevel border with the given parameters.
 void compoundBorder(Border[] borders)
          Adds a compound border constructed from the given array of borders.
 void compoundBorder(Border outer, Border inner)
          Adds a compound border constructed from the given outer and inner borders.
 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 emptyBorder(int thickness)
          Adds an empty border with the given thickness.
 void emptyBorder(int vgap, int hgap)
          Adds an empty border with the given gaps.
 void emptyBorder(int top, int left, int bottom, int right)
          Adds an empty border with the given parameters.
 void endAlert(AlertEvent evt)
          Turns off alert status for this component and its children that are also AlertListeners.
 void etchBorderLowered()
          Adds a default lowered etch border.
 void etchBorderLowered(Color highlight, Color shadow)
          Adds a lowered etch border with the given highlight and shadow colors.
 void etchBorderLowered(int levels, Color highlight, Color shadow)
          Adds a lowered etch border with the given parameters.
 void etchBorderRaised()
          Adds a default raised etch border.
 void etchBorderRaised(Color highlight, Color shadow)
          Adds a raised etch border with the given highlight and shadow colors.
 void etchBorderRaised(int levels, Color highlight, Color shadow)
          Adds a raised etch border with the given parameters.
 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 encoded default view state for the Displayable() objects in the panel.
 String[] getDefaultViewStates()
          Returns a String array of the default view states for the corresponding Displayable() items in the array returned by getDisplayables().
 Displayable[] getDisplayables()
          Returns an array of all Displayable objects installed as Components in this panel.
 String getViewState()
          Returns the encoded view state for the Displayable() objects in the panel.
 String[] getViewStates()
          Returns a String array of the view states for the corresponding Displayable() items in the array returned by getDisplayables().
 void lineBorder()
          Adds a line border with color black and thickness 1.
 void lineBorder(Color color)
          Adds a line border with the given color and thickness 1.
 void lineBorder(Color color, int thickness)
          Adds a line border with the given color and thickness.
 void lineBorder(int thickness)
          Adds a line border with color black and the given thickness.
 Component makeComponent(Object object)
          By default, this method will return the Component constructed using ComponentFactory.makeComponent.
 void matteBorder(int thickness, Color color)
          Adds a matte border with the given thickness and color.
 void matteBorder(int thickness, Icon tileicon)
          Adds a matte border with the given thickness and tileicon.
 void matteBorder(int vgap, int hgap, Color color)
          Adds a matte border with the given gaps and color.
 void matteBorder(int vgap, int hgap, Icon tileicon)
          Adds a matte border with the given gaps and tileicon.
 void matteBorder(int top, int left, int bottom, int right, Color color)
          Adds a matte border with the given parameters.
 void matteBorder(int top, int left, int bottom, int right, Icon tileicon)
          Adds a matte border with the given parameters.
 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.
 Border removeBorder()
          Removes the current border and returns it.
 void reset()
          Recursively resets any Displayable objects held in the panel.
 void sandwichBorder(Border center, Border wrap)
          Adds a sandwich border with the given center border in the middle and the wrap border as outer and inner.
 void setCodec(String codecID)
          Sets the identifier for the CODEC to be used to combine multiple child view states into an encoded String.
 void setDeepBackground(Color c)
          Sets the background of this object to the given color; then sets the background of each component within this object to the same color using setDeepBackground recursively for each component that happens to extend DisplayPanel or JPTComponent.
 void setDeepBackground(Color c, Class type)
          Sets the background of all components in the hierarchy of this object that are instances of the given class.
 void setDefaultViewState(String data)
          Sets the default view states for the Displayable objects in the container to the data encoded in the given String.
 void setDefaultViewStates(String[] data)
          Sets the default view states for the Displayable objects in the container to the corresponding elements in the given array of Strings.
 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 the Displayable objects in the container to the data encoded in the given String.
 void setViewStates(String[] data)
          Sets the view states for the Displayable objects in the container to the corresponding elements in the given array of Strings.
 void startAlert(AlertEvent evt)
          Turns on alert status for this component and its children that are also AlertListeners.
 void titleBorder(String t)
          Adds a title border with the given parameters.
 void titleBorder(String t, Border base)
          Adds a title border with the given parameters.
 void titleBorder(String t, Border base, Font font, Color fontcolor)
          Adds a title border with the given parameters.
 void titleBorder(String t, Font font, Color fontcolor)
          Adds a title border with the given parameters.
 void titleBorder(String t, int hPosition, int vPosition)
          Adds a title border with the given parameters.
 void titleBorder(String t, int hPosition, int vPosition, Border base)
          Adds a title border with the given parameters.
 void titleBorder(String t, int hPosition, int vPosition, Border base, Font font, Color fontcolor)
          Adds a title border with the given parameters.
 void titleBorder(String t, int hPosition, int vPosition, Font font, Color fontcolor)
          Adds a title border with the given parameters.
 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 javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CODEC

public static final String CODEC
Bound property name for the codec property.

See Also:
Constant Field Values

background

protected Color background
Background color before alert status was entered.


codec

protected String codec
Identifier for codec used by this panel.

Constructor Detail

DisplayPanel

public DisplayPanel()
Constructs a panel with the default layout manager for a JPanel.


DisplayPanel

public DisplayPanel(boolean isDoubleBuffered)
Constructs a panel with the default layout manager for a JPanel and the given double-buffering strategy.

Parameters:
isDoubleBuffered - whether or not the panel makes use of double-buffering

DisplayPanel

public DisplayPanel(LayoutManager layout)
Constructs a panel with the given layout manager.

Parameters:
layout - the desired layout manager

DisplayPanel

public DisplayPanel(LayoutManager layout,
                    boolean isDoubleBuffered)
Constructs a panel with the given layout manager and the given double-buffering strategy.

Parameters:
layout - the desired layout manager
isDoubleBuffered - whether or not the panel makes use of double-buffering
Method Detail

getDisplayables

public Displayable[] getDisplayables()

Returns an array of all Displayable objects installed as Components in this panel.

This method uses the Java method getComponent(int) to obtain Components in order and filter out those that implement the Displayable interface.

Returns a non-null empty array if this panel does not contain any Displayables.


setViewState

public void setViewState(String data)

Sets the view states for the Displayable objects in the container to the data encoded in the given String.

If the given encoded data is null, then the view states are not changed.

The String data is decoded using the method Strings.decode to allow the data to be submitted in several formats.

Sets the view states of as many Displayable objects as possible but ignores any mismatch in the number of Displayable objects and the number of Strings decoded from the given encoded String data.

Fires property change VIEW_STATE.

Specified by:
setViewState in interface Displayable
Parameters:
data - the encoded String data
See Also:
Displayable.getViewState()

setViewStates

public void setViewStates(String[] data)

Sets the view states for the Displayable objects in the container to the corresponding elements in the given array of Strings.

If the given data array is null, then the view states are not changed.

Sets the view states of as many Displayable objects as possible but ignores any mismatch in the number of Displayable objects and the number of Strings in the array.

Fires property change VIEW_STATE.

Parameters:
data - the view state array data

getViewState

public String getViewState()

Returns the encoded view state for the Displayable() objects in the panel.

The encoded data is constructed by passing the array returned by getViewStates() to the method CodecUtilities.encode. This method call uses the codec returned by the method getCodec().

Specified by:
getViewState in interface Displayable
Returns:
the view state as a String
See Also:
Displayable.setViewState(String)

getViewStates

public String[] getViewStates()

Returns a String array of the view states for the corresponding Displayable() items in the array returned by getDisplayables().


setDefaultViewState

public void setDefaultViewState(String data)

Sets the default view states for the Displayable objects in the container to the data encoded in the given String.

If the given encoded data is null, then the default view states are not changed.

The String data is decoded using the method Strings.decode to allow the data to be submitted in several formats.

Sets the default view states of as many Displayable objects as possible but ignores any mismatch in the number of Displayable objects and the number of Strings decoded from the given encoded String data.

Fires property change DEFAULT_VIEW_STATE.

Specified by:
setDefaultViewState in interface Displayable
Parameters:
data - the encoded default String data
See Also:
Displayable.getDefaultViewState(), Displayable.reset()

setDefaultViewStates

public void setDefaultViewStates(String[] data)

Sets the default view states for the Displayable objects in the container to the corresponding elements in the given array of Strings.

If the given data array is null, then the default view states are not changed.

Sets the default view states of as many Displayable objects as possible but ignores any mismatch in the number of Displayable objects and the number of Strings in the array.

Fires property change DEFAULT_VIEW_STATE.

Parameters:
data - the default view state array data

getDefaultViewState

public String getDefaultViewState()

Returns the encoded default view state for the Displayable() objects in the panel.

The encoded data is constructed by passing the array returned by getDefaultViewStates() to the method CodecUtilities.encode. This method call uses the codec returned by the method getCodec().

Specified by:
getDefaultViewState in interface Displayable
Returns:
the default view state as a String
See Also:
Displayable.setDefaultViewState(String), Displayable.reset()

getDefaultViewStates

public String[] getDefaultViewStates()

Returns a String array of the default view states for the corresponding Displayable() items in the array returned by getDisplayables().


setEnabled

public void setEnabled(boolean isEnabled)
Enables or disables the panel, and recursively enables or disables its contents, based on the given value.

Specified by:
setEnabled in interface Displayable
Parameters:
isEnabled - whether or not this panel is to be enabled

reset

public void reset()
Recursively resets any Displayable objects held in the panel.

Specified by:
reset in interface Displayable
See Also:
Displayable.setViewState(String), Displayable.getDefaultViewState()

dataMalformed

public 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.

Specified by:
dataMalformed in interface MalformedDataListener
Parameters:
evt - the malformed data event

startAlert

public void startAlert(AlertEvent evt)
Turns on alert status for this component and its children that are also AlertListeners.

Specified by:
startAlert in interface AlertListener
Parameters:
evt - the alert event

endAlert

public void endAlert(AlertEvent evt)
Turns off alert status for this component and its children that are also AlertListeners.

Specified by:
endAlert in interface AlertListener
Parameters:
evt - the alert event

addBorder

public Border addBorder(Border border)

Adds the given border as an outer wrapper around the current border of the component.

If the current border is null, then sets the given border as the border.

Does nothing if the given border is null.

Returns the final border of the component

Parameters:
border - the border to add as a wrapper

removeBorder

public Border removeBorder()

Removes the current border and returns it.


emptyBorder

public void emptyBorder(int thickness)

Adds an empty border with the given thickness.

Parameters:
thickness - the border thickness

emptyBorder

public void emptyBorder(int vgap,
                        int hgap)

Adds an empty border with the given gaps.

Parameters:
vgap - the border vertical gap: top and bottom
hgap - the border horizontal gap: left and right

emptyBorder

public void emptyBorder(int top,
                        int left,
                        int bottom,
                        int right)

Adds an empty border with the given parameters.

Parameters:
top - the border top
left - the border left
bottom - the border bottom
right - the border right

matteBorder

public void matteBorder(int thickness,
                        Color color)

Adds a matte border with the given thickness and color.

If the color is null, it is set to the color Color.black.

Parameters:
thickness - the border thickness
color - the border color

matteBorder

public void matteBorder(int vgap,
                        int hgap,
                        Color color)

Adds a matte border with the given gaps and color.

If the color is null, it is set to the color Color.black.

Parameters:
vgap - the border vertical gap: top and bottom
hgap - the border horizontal gap: left and right
color - the border color

matteBorder

public void matteBorder(int top,
                        int left,
                        int bottom,
                        int right,
                        Color color)

Adds a matte border with the given parameters.

If the color is null, it is set to the color Color.black.

Parameters:
top - the border top
left - the border left
bottom - the border bottom
right - the border right
color - the border color

matteBorder

public void matteBorder(int thickness,
                        Icon tileicon)

Adds a matte border with the given thickness and tileicon.

If the tileicon is null, it is replaced by the color Color.black.

Parameters:
thickness - the border thickness
tileicon - the border tileicon

matteBorder

public void matteBorder(int vgap,
                        int hgap,
                        Icon tileicon)

Adds a matte border with the given gaps and tileicon.

If the tileicon is null, it is replaced by the color Color.black.

Parameters:
vgap - the border vertical gap: top and bottom
hgap - the border horizontal gap: left and right
tileicon - the border tileicon

matteBorder

public void matteBorder(int top,
                        int left,
                        int bottom,
                        int right,
                        Icon tileicon)

Adds a matte border with the given parameters.

If the tileicon is null, it is replaced by the color Color.black.

Parameters:
top - the border top
left - the border left
bottom - the border bottom
right - the border right
tileicon - the border tileicon

lineBorder

public void lineBorder()

Adds a line border with color black and thickness 1.


lineBorder

public void lineBorder(Color color)

Adds a line border with the given color and thickness 1.

If the color is null, it is set to the color Color.black.

Parameters:
color - the border color

lineBorder

public void lineBorder(int thickness)

Adds a line border with color black and the given thickness.

Parameters:
thickness - the border thickness

lineBorder

public void lineBorder(Color color,
                       int thickness)

Adds a line border with the given color and thickness.

If the color is null, it is set to the color Color.black.

Note that the effect of this method is the same as:

   matteBorder(thickness, color);

but the parameters are in the opposite order.

Parameters:
color - the border color
thickness - the border thickness

etchBorderLowered

public void etchBorderLowered()

Adds a default lowered etch border.


etchBorderLowered

public void etchBorderLowered(Color highlight,
                              Color shadow)

Adds a lowered etch border with the given highlight and shadow colors.

Parameters:
highlight - the highlight color
shadow - the shadow color

etchBorderLowered

public void etchBorderLowered(int levels,
                              Color highlight,
                              Color shadow)

Adds a lowered etch border with the given parameters.

Parameters:
levels - the number of levels in each color band
highlight - the highlight color
shadow - the shadow color

etchBorderRaised

public void etchBorderRaised()

Adds a default raised etch border.


etchBorderRaised

public void etchBorderRaised(Color highlight,
                             Color shadow)

Adds a raised etch border with the given highlight and shadow colors.

Parameters:
highlight - the highlight color
shadow - the shadow color

etchBorderRaised

public void etchBorderRaised(int levels,
                             Color highlight,
                             Color shadow)

Adds a raised etch border with the given parameters.

Parameters:
levels - the number of levels in each color band
highlight - the highlight color
shadow - the shadow color

bevelBorderLowered

public void bevelBorderLowered()

Adds a default lowered bevel border.


bevelBorderLowered

public void bevelBorderLowered(Color highlight,
                               Color shadow)

Adds a lowered bevel border with the given highlight and shadow colors.

Parameters:
highlight - the highlight color
shadow - the shadow color

bevelBorderLowered

public void bevelBorderLowered(Color highlightOuter,
                               Color highlightInner,
                               Color shadowInner,
                               Color shadowOuter)

Adds a lowered bevel border with the given colors.

The parameter order outer-inner-inner-outer is different from that used in the Java class BorderFactory for similar methods.

Parameters:
highlightOuter - the outer highlight color
highlightInner - the inner highlight color
shadowInner - the inner shadow color
shadowOuter - the outer shadow color

bevelBorderLowered

public void bevelBorderLowered(int levels,
                               Color highlight,
                               Color shadow)

Adds a lowered bevel border with the given parameters.

Parameters:
levels - the thickness of each edge
highlight - the highlight color
shadow - the shadow color

bevelBorderLowered

public void bevelBorderLowered(int levels,
                               Color highlightOuter,
                               Color highlightInner,
                               Color shadowInner,
                               Color shadowOuter)

Adds a lowered bevel border with the given parameters.

The parameter order outer-inner-inner-outer is different from that used in the Java class BorderFactory for similar methods.

Parameters:
levels - the thickness of each edge
highlightOuter - the outer highlight color
highlightInner - the inner highlight color
shadowInner - the inner shadow color
shadowOuter - the outer shadow color

bevelBorderRaised

public void bevelBorderRaised()

Adds a raised bevel border.


bevelBorderRaised

public void bevelBorderRaised(Color highlight,
                              Color shadow)

Adds a raised bevel border with the given highlight and shadow colors.

Parameters:
highlight - the highlight color
shadow - the shadow color

bevelBorderRaised

public void bevelBorderRaised(Color highlightOuter,
                              Color highlightInner,
                              Color shadowInner,
                              Color shadowOuter)

Adds a raised bevel border with the given colors.

The parameter order outer-inner-inner-outer is different from that used in the Java class BorderFactory for similar methods.

Parameters:
highlightOuter - the outer highlight color
highlightInner - the inner highlight color
shadowInner - the inner shadow color
shadowOuter - the outer shadow color

bevelBorderRaised

public void bevelBorderRaised(int levels,
                              Color highlight,
                              Color shadow)

Adds a raised bevel border with the given parameters.

Parameters:
levels - the thickness of each edge
highlight - the highlight color
shadow - the shadow color

bevelBorderRaised

public void bevelBorderRaised(int levels,
                              Color highlightOuter,
                              Color highlightInner,
                              Color shadowInner,
                              Color shadowOuter)

Adds a raised bevel border with the given parameters.

The parameter order outer-inner-inner-outer is different from that used in the Java class BorderFactory for similar methods.

Parameters:
levels - the thickness of each edge
highlightOuter - the outer highlight color
highlightInner - the inner highlight color
shadowInner - the inner shadow color
shadowOuter - the outer shadow color

titleBorder

public void titleBorder(String t)

Adds a title border with the given parameters.

If t is null, it is set to an empty string.

The title is centered in the top position.

A title is inserted into an existing border. This constructor uses a default line border of thickness 2 in black.

Parameters:
t - the title string

titleBorder

public void titleBorder(String t,
                        Border base)

Adds a title border with the given parameters.

If t is null, it is set to an empty string.

The title is centered in the top position.

A title is inserted into an existing border. If the base is non-null that border is used; otherwise a default line border is used. We have changed the default line border to a line border of thickness 2 in black. The Java default is of thickness 1 and is in a pale blue that is almost invisible.

Parameters:
t - the title string
base - the base border in which to place the title

titleBorder

public void titleBorder(String t,
                        Font font,
                        Color fontcolor)

Adds a title border with the given parameters.

If t is null, it is set to an empty string.

The title is centered in the top position.

A title is inserted into an existing border. This constructor uses a default line border of thickness 2 in black.

The font and fontcolor may be supplied or left as null to accept defaults.

Parameters:
t - the title string
font - the title font
fontcolor - the title font color

titleBorder

public void titleBorder(String t,
                        Border base,
                        Font font,
                        Color fontcolor)

Adds a title border with the given parameters.

If t is null, it is set to an empty string.

The title is centered in the top position.

A title is inserted into an existing border. If the base is non-null that border is used; otherwise a default line border is used. We have changed the default line border to a line border of thickness 2 in black. The Java default is of thickness 1 and is in a pale blue that is almost invisible.

The font and fontcolor may be supplied or left as null to accept defaults.

Parameters:
t - the title string
base - the base border in which to place the title
font - the title font
fontcolor - the title font color

titleBorder

public void titleBorder(String t,
                        int hPosition,
                        int vPosition)

Adds a title border with the given parameters.

If t is null, it is set to an empty string.

The valid values for hPosition are:

The valid values for vPosition are:

If either hPosition or vPosition are invalid, they are set to the corresponding default.

The constants listed above are defined in the Java class TitledBorder except for the default constants. All constants are redefined in this class and the defaults are added as specified above.

A title is inserted into an existing border. This constructor uses a default line border of thickness 2 in black.

Parameters:
t - the title string
hPosition - the horizontal position
vPosition - the vertical position

titleBorder

public void titleBorder(String t,
                        int hPosition,
                        int vPosition,
                        Border base)

Adds a title border with the given parameters.

If t is null, it is set to an empty string.

The valid values for hPosition are:

The valid values for vPosition are:

If either hPosition or vPosition are invalid, they are set to the corresponding default.

The constants listed above are defined in the Java class TitledBorder except for the default constants. All constants are redefined in this class and the defaults are added as specified above.

A title is inserted into an existing border. If the base is non-null that border is used; otherwise a default line border is used. We have changed the default line border to a line border of thickness 2 in black. The Java default is of thickness 1 and is in a pale blue that is almost invisible.

Parameters:
t - the title string
hPosition - the horizontal position
vPosition - the vertical position
base - the base border in which to place the title

titleBorder

public void titleBorder(String t,
                        int hPosition,
                        int vPosition,
                        Font font,
                        Color fontcolor)

Adds a title border with the given parameters.

If t is null, it is set to an empty string.

The valid values for hPosition are:

The valid values for vPosition are:

If either hPosition or vPosition are invalid, they are set to the corresponding default.

The constants listed above are defined in the Java class TitledBorder except for the default constants. All constants are redefined in this class and the defaults are added as specified above.

A title is inserted into an existing border. This constructor uses a default line border of thickness 2 in black.

The font and fontcolor may be supplied or left as null to accept defaults.

Parameters:
t - the title string
hPosition - the horizontal position
vPosition - the vertical position
font - the title font
fontcolor - the title font color

titleBorder

public void titleBorder(String t,
                        int hPosition,
                        int vPosition,
                        Border base,
                        Font font,
                        Color fontcolor)

Adds a title border with the given parameters.

If t is null, it is set to an empty string.

The valid values for hPosition are:

The valid values for vPosition are:

If either hPosition or vPosition are invalid, they are set to the corresponding default.

The constants listed above are defined in the Java class TitledBorder except for the default constants. All constants are redefined in this class and the defaults are added as specified above.

A title is inserted into an existing border. If the base is non-null that border is used; otherwise a default line border is used. We have changed the default line border to a line border of thickness 2 in black. The Java default is of thickness 1 and is in a pale blue that is almost invisible.

The font and fontcolor may be supplied or left as null to accept defaults.

Parameters:
t - the title string
hPosition - the horizontal position
vPosition - the vertical position
base - the base border in which to place the title
font - the title font
fontcolor - the title font color

compoundBorder

public void compoundBorder(Border outer,
                           Border inner)

Adds a compound border constructed from the given outer and inner borders.

If either border is null, the other is added alone.

Parameters:
outer - the outer border
inner - the inner border

compoundBorder

public void compoundBorder(Border[] borders)

Adds a compound border constructed from the given array of borders.

The initial border in the array will be the outermost border in the compound.

The sequence of array elements is viewed as outermost to innermost.

Parameters:
borders - an array of borders to compound

sandwichBorder

public void sandwichBorder(Border center,
                           Border wrap)

Adds a sandwich border with the given center border in the middle and the wrap border as outer and inner.

Parameters:
center - the border in the middle
wrap - the border to wrap as both outer and inner

setDeepBackground

public void setDeepBackground(Color c)
Sets the background of this object to the given color; then sets the background of each component within this object to the same color using setDeepBackground recursively for each component that happens to extend DisplayPanel or JPTComponent.

Parameters:
c - the background color

setDeepBackground

public void setDeepBackground(Color c,
                              Class type)

Sets the background of all components in the hierarchy of this object that are instances of the given class.

The background of the object itself will be set only if it is an instance of the given class.

The hierarchy is determined recursively as entities in instances of either DisplayPanel or JPTComponent.

Parameters:
c - the background color
type - the class whose objects should change

add

public Component add(Component c)
Adds the specified component to the end of this container.

Parameters:
c - the component to be added
Returns:
the component argument

add

public Component add(Component c,
                     int index)
Adds the specified component to this container at the given position.

Parameters:
c - the component to be added
index - the position at which to insert the component, or -1 to insert the component at the end.
Returns:
the component argument

add

public void add(Component c,
                Object constraints)
Adds the specified component to the end of this container. Also notifies the layout manager to add the component to this container's layout using the given constraints object.

Parameters:
c - the component to be added
constraints - an object expressing layout constraints for this component

add

public void add(Component c,
                Object constraints,
                int index)
Adds the specified component at the given position. Also notifies the layout manager to add the component to this container's layout using the specified constraints object.

Parameters:
c - the component to be added
constraints - an object expressing layout constraints for this component
index - the position at which to insert the component, or -1 to insert the component at the end.

add

public Component add(String name,
                     Component c)
Adds the given component to this container. It is strongly advised to use the 1.1 method, add(Component, Object), in place of this method.

Parameters:
name - the name of the component to be added
c - the component to be added
Returns:
the component argument

addObject

public Component addObject(Object object)
Add the given object to this DisplayPanel at the next available position after applying the transformation of the method makeComponent.

Parameters:
object - the object to be transformed and added to the panel
Returns:
the component obtained by transforming the object
Since:
2.2

addObject

public 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.

Parameters:
object - the object to be transformed and added to the panel
index - the position at which to add the component
Returns:
the component obtained by transforming the object
Since:
2.2

addObject

public 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.

Parameters:
object - the object to be transformed and added to the panel
constraints - an object expressing layout constraints for the component
Returns:
the component obtained by transforming the object
Since:
2.2

addObject

public 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.

Parameters:
object - the object to be transformed and added to the panel
constraints - an object expressing layout constraints for the component
index - the position at which to add the component
Returns:
the component obtained by transforming the object
Since:
2.2

makeComponent

public Component makeComponent(Object object)
By default, this method will return the Component constructed using ComponentFactory.makeComponent.

Parameters:
object - the object to be transformed
Returns:
the component obtained by transforming the object
Since:
2.2

remove

public void remove(Component c)
Removes the given component from this container.

Parameters:
c - the component to be removed

remove

public void remove(int index)
Removes the component at the given index from this container.

Parameters:
index - the index of the component to be removed

removeAll

public void removeAll()
Removes all of the components from this container.


uniformizeSize

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.

Since:
2.0

uniformizeWidth

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.

Since:
2.3

uniformizeHeight

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.

Since:
2.3

setCodec

public void setCodec(String codecID)
Sets the identifier for the CODEC to be used to combine multiple child view states into an encoded String. If the given identifier is null, the CODEC is not changed.

Parameters:
codecID - identifier of the codec to be used

getCodec

public String getCodec()
Returns the identifier for the current CODEC to be used to combine multiple child view states into an encoded String.


frame

public JPTFrame frame()

Frame this panel in a JPTFrame and open the frame; return the frame constructed.

Returns:
the frame constructed
Since:
2.3.3

frame

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.

Parameters:
location - the constant representing the frame location
Returns:
the frame constructed
Since:
2.3.3

frame

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.

Parameters:
title - the title for the frame
Returns:
the frame constructed
Since:
2.3.3

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.

Parameters:
title - the title for the frame
location - the constant representing the frame location
Returns:
the frame constructed
Since:
2.3.3

frame

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.

Parameters:
title - the title for the frame
insets - the screen insets to use to adjust the location
Returns:
the frame constructed
Since:
2.3.4

frame

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.

Parameters:
title - the title for the frame
location - the constant representing the frame location
insets - the screen insets to use to adjust the location
Returns:
the frame constructed
Since:
2.3.3

OKDialog

public GeneralDialog OKDialog()

Place this panel in a modal OK dialog and open the dialog; return the dialog constructed.

Returns:
the dialog constructed
Since:
2.3.3

OKDialog

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.

Parameters:
title - the title for the dialog
Returns:
the dialog constructed
Since:
2.3.3

OKCancelDialog

public GeneralDialog OKCancelDialog()

Place this panel in a modal OK-Cancel dialog and open the dialog; return the dialog constructed.

Returns:
the dialog constructed
Since:
2.3.3

OKCancelDialog

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.

Parameters:
title - the title for the dialog
Returns:
the dialog constructed
Since:
2.3.3

YesNoCancelDialog

public GeneralDialog YesNoCancelDialog()

Place this panel in a modal Yes-No-Cancel dialog and open the dialog; return the dialog constructed.

Returns:
the dialog constructed
Since:
2.3.3

YesNoCancelDialog

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.

Parameters:
title - the title for the dialog
Returns:
the dialog constructed
Since:
2.3.3

generalDialog

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:

If 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:

If the option parameter is not specified, it is taken to be DialogAction.AUTO_CLOSE.

Parameters:
actionData - the action data
Returns:
the dialog constructed
Since:
2.3.3

generalDialog

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:

If 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:

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.

Parameters:
actionData - the action data
defaultAction - the default action
Returns:
the dialog constructed
Since:
2.3.3

generalDialog

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:

If 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:

If the option parameter is not specified, it is taken to be DialogAction.AUTO_CLOSE.

Parameters:
title - the title for the dialog
actionData - the action data
Returns:
the dialog constructed
Since:
2.3.3

generalDialog

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:

If 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:

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.

Parameters:
title - the title for the dialog
actionData - the action data
defaultAction - the default action
Returns:
the dialog constructed
Since:
2.3.3

refreshComponent

public void refreshComponent()
Refreshes the component by repacking the parent window.