|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
sim.util.gui.PropertyField
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.
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
|
int |
displayState
|
java.awt.Color |
editedColor
|
javax.swing.border.Border |
emptyBorder
|
boolean |
isReadWrite
|
java.awt.event.KeyListener |
listener
|
javax.swing.JLabel |
optionalLabel
|
static int |
SHOW_CHECKBOX
|
static int |
SHOW_TEXTFIELD
|
static int |
SHOW_VIEWBUTTON
|
javax.swing.JPanel |
switcher
|
javax.swing.JTextField |
valField
|
javax.swing.border.Border |
valFieldBorder
|
javax.swing.JButton |
viewButton
|
java.awt.event.ActionListener |
viewButtonListener
|
javax.swing.JLabel |
viewLabel
|
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.awt.Dimension |
getMinimumSize()
|
java.awt.Dimension |
getPreferredSize()
|
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. |
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, getNextFocusableComponent, 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 |
public javax.swing.JTextField valField
public javax.swing.JCheckBox checkField
public javax.swing.JButton viewButton
public javax.swing.JLabel viewLabel
public javax.swing.JLabel optionalLabel
public javax.swing.JPanel switcher
public javax.swing.border.Border valFieldBorder
public javax.swing.border.Border emptyBorder
public java.lang.String currentValue
public boolean isReadWrite
public int displayState
public static final int SHOW_CHECKBOX
public static final int SHOW_TEXTFIELD
public static final int SHOW_VIEWBUTTON
public java.awt.Color defaultColor
public java.awt.Color editedColor
public java.awt.event.KeyListener listener
public java.awt.event.ActionListener checkListener
public java.awt.event.ActionListener viewButtonListener
Constructor Detail |
public PropertyField()
public PropertyField(java.lang.String initialValue)
public PropertyField(java.lang.String initialValue, boolean isReadWrite)
public PropertyField(java.lang.String label, java.lang.String initialValue)
public PropertyField(java.lang.String label, java.lang.String initialValue, boolean isReadWrite)
public PropertyField(java.lang.String label, java.lang.String initialValue, boolean isReadWrite, int show)
Method Detail |
public void setEditedColor(java.awt.Color c)
public java.awt.Color getEditedColor()
public void setValue(java.lang.String val)
public java.lang.String getValue()
public void setValues(java.lang.String label, java.lang.String initialValue, boolean isReadWrite, int show)
public java.lang.String newValue(java.lang.String newValue)
public void viewProperty()
public void setToolTipText(java.lang.String text)
public java.awt.Dimension getMinimumSize()
public java.awt.Dimension getPreferredSize()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |