Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## sim.util.gui
Class PropertyField

    java.lang.Object
      java.awt.Component
          java.awt.Container
              javax.swing.JComponent
                  sim.util.gui.PropertyField

All Implemented Interfaces:
  java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class PropertyField
extends javax.swing.JComponent

A simple class that lets you specify a label and validate a string. PropertyField lets you control the values which the user sets by subclassing the class and overriding the newValue(val) method filters all newly user-set values and "corrects" them. Programmatically set values (by calling setValue(...)) are not filtered through newValue by default. If you need to filter, you should do setValue(newValue(val));

You can optionally specify a type for the property to be set. At present the only value this type can take on is boolean (Boolean.TYPE). If boolean, then the PropertyField will display a checkbox rather than a text field for the user to enter. Additionally, if the PropertyField constructed read-only, then a JLabel (rather than text field) or a disabled checkbox will be shown.

PropertyField can also be provided with an optional label.

See Also:
  Serialized Form

Nested Class Summary

Nested classes inherited from class javax.swing.JComponent
`javax.swing.JComponent.AccessibleJComponent`

Nested classes inherited from class java.awt.Container
`java.awt.Container.AccessibleAWTContainer`

Nested classes inherited from class java.awt.Component
`java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy`

Field Summary
`javax.swing.JCheckBox` | `checkField`
`java.awt.event.ActionListener` | `checkListener`
`java.lang.String` | `currentValue`
`java.awt.Color` | `defaultColor`
`java.awt.Color` | `editedColor`
`java.awt.event.KeyListener` | `listener`
`javax.swing.JLabel` | `readOnlyValField`
`static int` | `SHOW_CHECKBOX`
`static int` | `SHOW_TEXTFIELD`
`static int` | `SHOW_VIEWBUTTON`
`javax.swing.JTextField` | `valField`
`javax.swing.JButton` | `viewButton`
`java.awt.event.ActionListener` | `viewButtonListener`

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
`PropertyField()`
`PropertyField(java.lang.String initialValue)` This looks just like a JTextField
`PropertyField(java.lang.String initialValue, boolean isReadWrite)` if isReadWrite is false, then this looks just like a JLabel; else it looks just like a JTextField
`PropertyField(java.lang.String label, java.lang.String initialValue)`
`PropertyField(java.lang.String label, java.lang.String initialValue, boolean isReadWrite)`
`PropertyField(java.lang.String label, java.lang.String initialValue, boolean isReadWrite, int show)` If show is SHOW_CHECKBOX, a checkbox will be shown (expecting "true" and "false" string values).

Method Summary
`java.awt.Color` | `getEditedColor()`
`java.lang.String` | `getValue()` Returns the most recently set value.
`java.lang.String` | `newValue(java.lang.String newValue)` Override this to be informed when a new value has been set.
`void` | `setEditedColor(java.awt.Color c)`
`void` | `setToolTipText(java.lang.String text)`
`void` | `setValue(java.lang.String val)` Sets the value, filtering it through newValue(val) first.
`protected void` | `setValues(java.lang.String label, java.lang.String initialValue, boolean isReadWrite, int show)`
`void` | `viewProperty()` Override this to be informed when a property is to be viewed in its own inspector because the user pressed the "view" button.

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, 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`

Field Detail

### valField

    public javax.swing.JTextField valField

### checkField

    public javax.swing.JCheckBox checkField

### readOnlyValField

    public javax.swing.JLabel readOnlyValField

### viewButton

    public javax.swing.JButton viewButton

### currentValue

    public java.lang.String currentValue

### SHOW_CHECKBOX

    public static final int SHOW_CHECKBOX

See Also:
  Constant Field Values

### SHOW_TEXTFIELD

    public static final int SHOW_TEXTFIELD

See Also:
  Constant Field Values

### SHOW_VIEWBUTTON

    public static final int SHOW_VIEWBUTTON

See Also:
  Constant Field Values

### defaultColor

    public java.awt.Color defaultColor

### editedColor

    public java.awt.Color editedColor

### listener

    public java.awt.event.KeyListener listener

### checkListener

    public java.awt.event.ActionListener checkListener

### viewButtonListener

    public java.awt.event.ActionListener viewButtonListener

Constructor Detail

### PropertyField

    public PropertyField()

### PropertyField

    public PropertyField(java.lang.String initialValue)

  This looks just like a JTextField

### PropertyField

    public PropertyField(java.lang.String initialValue,
                         boolean isReadWrite)

  if isReadWrite is false, then this looks just like a JLabel; else it looks just like a JTextField

### PropertyField

    public PropertyField(java.lang.String label,
                         java.lang.String initialValue)

### PropertyField

    public PropertyField(java.lang.String label,
                         java.lang.String initialValue,
                         boolean isReadWrite)

### PropertyField

    public PropertyField(java.lang.String label,
                         java.lang.String initialValue,
                         boolean isReadWrite,
                         int show)

  If show is SHOW_CHECKBOX, a checkbox will be shown (expecting "true" and "false" string values). If show is SHOW_VIEWBUTTON, a view button will be shown (expecting a true object). If show is SHOW_TEXTFIELD, a textfield will be shown.

Method Detail

### setEditedColor

    public void setEditedColor(java.awt.Color c)

### getEditedColor

    public java.awt.Color getEditedColor()

### setValue

    public void setValue(java.lang.String val)

  Sets the value, filtering it through newValue(val) first.

### getValue

    public java.lang.String getValue()

  Returns the most recently set value.

### setValues

    protected void setValues(java.lang.String label,
                             java.lang.String initialValue,
                             boolean isReadWrite,
                             int show)

### newValue

    public java.lang.String newValue(java.lang.String newValue)

  Override this to be informed when a new value has been set. The return value should be the value you want the display to show instead.

### viewProperty

    public void viewProperty()

  Override this to be informed when a property is to be viewed in its own inspector because the user pressed the "view" button.

### setToolTipText

    public void setToolTipText(java.lang.String text)

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD