edu.stanford.nlp.swing
Class PropertyPanel

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byedu.stanford.nlp.swing.PropertyPanel
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable

public class PropertyPanel
extends JComponent

UI for a key/value property with an on/off checkbox. The key is a label, the value is a text box, and the checkbox turns the property on and off. If the property is required, the checkbox is always on. When the checkbox is off, the text field is disabled.

Author:
Joseph Smarr (jsmarr@stanford.edu)
See Also:
Serialized Form

Nested Class Summary
 
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
 
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 java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
PropertyPanel()
          Constructs a new PropertyPanel with nothing initially set.
PropertyPanel(String key, String value, String defaultValue, String description, boolean required, Object propertyClass)
          Constructs a new PropertyPanel with the given initial values.
 
Method Summary
 String getDefaultValue()
           
 String getDescription()
           
 String getKey()
           
 int getPreferredLabelWidth()
          Gets the preferred width of the label displaying the property key.
 Object getPropertyClass()
           
 String getValue()
           
 boolean isOn()
           
 boolean isRequired()
           
static void main(String[] args)
          For internal debugging purposes only.
 void selectValueField()
          Transfers focus to this PropertyPanel's value text field and selects the text.
 void setDefaultValue(String defaultValue)
           
 void setDescription(String description)
           
 void setKey(String key)
           
 void setOn(boolean on)
           
 void setPreferredLabelWidth(int width)
          Sets the preferred width of the label displaying the property key.
 void setPropertyClass(Object classInstance)
          Changes the property value editor to support editing objects of the given class type.
 void setRequired(boolean required)
          Sets whether this property is required to be on.
 void setValue(String value)
           
static void synchronizeLabelWidths(PropertyPanel[] panels)
          Sets the preferred label width of each of the given panels to the max preferred width of any of the panels.
 
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, getAccessibleContext, 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, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, 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, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, 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, remove, remove, removeAll, 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
 

Constructor Detail

PropertyPanel

public PropertyPanel()
Constructs a new PropertyPanel with nothing initially set.


PropertyPanel

public PropertyPanel(String key,
                     String value,
                     String defaultValue,
                     String description,
                     boolean required,
                     Object propertyClass)
Constructs a new PropertyPanel with the given initial values. The property will be initially on if the value is not null or if required is true. If the value is null, the checkbox will initially be off, but the text field will not be disabled (as it normally would when the checkbox is off). The first time the user types in the text field, the checkbox is turned on, and from there on it behaves normally. This is to save the user from having to explicitly turn on every property before using it the first time.

Method Detail

getPreferredLabelWidth

public int getPreferredLabelWidth()
Gets the preferred width of the label displaying the property key.


setPreferredLabelWidth

public void setPreferredLabelWidth(int width)
Sets the preferred width of the label displaying the property key.


synchronizeLabelWidths

public static void synchronizeLabelWidths(PropertyPanel[] panels)
Sets the preferred label width of each of the given panels to the max preferred width of any of the panels. This is useful for laying out a column of property panels and ensuring their text fields all line up.


getKey

public String getKey()

getValue

public String getValue()

getDefaultValue

public String getDefaultValue()

getDescription

public String getDescription()

isOn

public boolean isOn()

isRequired

public boolean isRequired()

getPropertyClass

public Object getPropertyClass()

setKey

public void setKey(String key)

setValue

public void setValue(String value)

setDefaultValue

public void setDefaultValue(String defaultValue)

setDescription

public void setDescription(String description)

setOn

public void setOn(boolean on)

setRequired

public void setRequired(boolean required)
Sets whether this property is required to be on. If so, forces the checkbox to be selected and disables de-selecting it.


setPropertyClass

public void setPropertyClass(Object classInstance)
Changes the property value editor to support editing objects of the given class type. If classInstance is null, it is assumed the property is a generic string. In addition, the following other object types are supported, with the following behaviors:


selectValueField

public void selectValueField()
Transfers focus to this PropertyPanel's value text field and selects the text. This may be appropriate to streamline correction when a bad property value is entered.


main

public static void main(String[] args)
For internal debugging purposes only.



Stanford NLP Group