net.sourceforge.sillyview
Class JPanelView

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.Box
                  extended by net.sourceforge.sillyview.JPanelView
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, WidgetView

public class JPanelView
extends Box
implements WidgetView

This is a central class in sillyview. It displays a given WidgetModel as a JLabel, a JEditorPane, or a HTMLPane. For implementation reasons it extends javax.swing.Box, instead of javax.swing.JPanel.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.Box
Box.AccessibleBox, Box.Filler
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  Object comp
          The component that the data is displayed in.
protected  JEditorPane ed
          If data displayed in a JEditorPane, this is that JEditorPane.
static int HTMLPANE
          If you want data displayed in a HTMLPane.
static String HYPERLINK_LISTENER
          A token for setting the view's hyperlink listener.
static int JEDITORPANE
          If you want data displayed in a JEditorPane.
static int JLABEL
          If you want data displayed in a JLabel.
protected  JLabel lab
          If data displayed as a JLabel, this is that JLabel.
protected  WidgetModel mod
          The model this view gets its data from.
static String TEXT
          A token for setting the view's text.
protected  String title
          This panel's title.
 
Fields inherited from class javax.swing.Box
accessibleContext
 
Fields inherited from class javax.swing.JComponent
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 net.sourceforge.sillyview.WidgetView
FALSE, TITLE, TRUE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
JPanelView(WidgetModel model, int componentType)
          Creates a new JPanelView instance backed by the given WidgetModel and of type JLABEL, JEDITORPANE, or HTMLPANE.
 
Method Summary
 void addTokens(Map<Object,Object> props)
          Adds all the name/value pairs and then updates the model.
 WidgetModel getModel()
          Returns the backing model.
 String getText()
          Gets this view's text.
 Object getValue(Object key)
          Gets the named value.
 void setAutoDump(boolean b)
          If the view component is a HTMLPane, will set its autodump property.
 void setMinimumSize(Dimension size)
          Sets the minimum size of this panel as well as the view component.
 void setModel(WidgetModel newModel)
          Sets the backing model.
 void setPreferredSize(Dimension size)
          Sets the preferred size of this panel as well as the view component.
protected  void setText(String txt)
          Sets this views text.
protected  void setTitle(String val)
          Sets the panel's title to the given text, providing a titled border.
 void setToken(Object key, Object value)
          Sets the named token to the given value and then recalculates my text.
 
Methods inherited from class javax.swing.Box
createGlue, createHorizontalBox, createHorizontalGlue, createHorizontalStrut, createRigidArea, createVerticalBox, createVerticalGlue, createVerticalStrut, getAccessibleContext, setLayout
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setNextFocusableComponent, setOpaque, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, 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, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, 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

title

protected String title
This panel's title.


lab

protected JLabel lab
If data displayed as a JLabel, this is that JLabel.


ed

protected JEditorPane ed
If data displayed in a JEditorPane, this is that JEditorPane.


comp

protected Object comp
The component that the data is displayed in.


mod

protected WidgetModel mod
The model this view gets its data from.


TEXT

public static final String TEXT
A token for setting the view's text.

See Also:
Constant Field Values

HYPERLINK_LISTENER

public static final String HYPERLINK_LISTENER
A token for setting the view's hyperlink listener.

See Also:
Constant Field Values

JLABEL

public static final int JLABEL
If you want data displayed in a JLabel.

See Also:
Constant Field Values

JEDITORPANE

public static final int JEDITORPANE
If you want data displayed in a JEditorPane.

See Also:
Constant Field Values

HTMLPANE

public static final int HTMLPANE
If you want data displayed in a HTMLPane.

See Also:
Constant Field Values
Constructor Detail

JPanelView

public JPanelView(WidgetModel model,
                  int componentType)
Creates a new JPanelView instance backed by the given WidgetModel and of type JLABEL, JEDITORPANE, or HTMLPANE.

Parameters:
model - a WidgetModel value
componentType - an int value
Method Detail

setText

protected void setText(String txt)
Sets this views text.

Parameters:
txt - a String value

getText

public String getText()
Gets this view's text.

Returns:
a String value

addTokens

public final void addTokens(Map<Object,Object> props)
Adds all the name/value pairs and then updates the model. If the named token already exists, replace the value. This is more efficient than many calls to setToken(), because model.getCurrentModel is only called once.

Specified by:
addTokens in interface WidgetView
Parameters:
props - a Map value

setToken

public final void setToken(Object key,
                           Object value)
Sets the named token to the given value and then recalculates my text. Most tokens, other than TITLE and HYPERLINK_LISTENER will be passed on to the model for handling.

Specified by:
setToken in interface WidgetView
Parameters:
key - an Object value
value - an Object value

getValue

public final Object getValue(Object key)
Gets the named value. Most values will come from the backing model.

Specified by:
getValue in interface WidgetView
Parameters:
key - an Object value
Returns:
an Object value

setTitle

protected final void setTitle(String val)
Sets the panel's title to the given text, providing a titled border.

Parameters:
val - a String value

getModel

public final WidgetModel getModel()
Returns the backing model.

Specified by:
getModel in interface WidgetView
Returns:
a WidgetModel value

setModel

public final void setModel(WidgetModel newModel)
Sets the backing model.

Specified by:
setModel in interface WidgetView
Parameters:
newModel - a WidgetModel value

setPreferredSize

public void setPreferredSize(Dimension size)
Sets the preferred size of this panel as well as the view component.

Overrides:
setPreferredSize in class JComponent
Parameters:
size - a java.awt.Dimension value

setMinimumSize

public void setMinimumSize(Dimension size)
Sets the minimum size of this panel as well as the view component.

Overrides:
setMinimumSize in class JComponent
Parameters:
size - a java.awt.Dimension value

setAutoDump

public void setAutoDump(boolean b)
If the view component is a HTMLPane, will set its autodump property.

Parameters:
b - a boolean value