public class PropertyField
extends javax.swing.JComponent
You can optionally specify how the string will be presented to the user: as a text field, as a text field with a slider (requiring certain numerical constraints on the text field), as a list of options (also requiring certain numerical constraints), as a check box (requiring the string to hold boolean values ("true" or "false"), or as a read-only field with a button to press (which in turn calls the viewProperty() method, which you may override).
The specifics about how to present the user with these options is described in the constructor documentation and in the documentation for setValues(...).
PropertyFields can also be set to be either read-only or read/write by the user. When the user edits a read/write PropertyField, the text field changes color. If the user then presses RETURN, the result is submitted to newValue(...). If the user presses ESCAPE, the result is cancelled and reset.
javax.swing.JComponent.AccessibleJComponent
Modifier and Type | Field and Description |
---|---|
static int |
SHOW_CHECKBOX |
static int |
SHOW_LIST |
static int |
SHOW_SLIDER |
static int |
SHOW_TEXTFIELD |
static int |
SHOW_VIEWBUTTON |
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Constructor and Description |
---|
PropertyField()
Constructs a PropertyField as just a writeable, empty text field.
|
PropertyField(java.lang.String initialValue)
Constructs a PropertyField as a writeable text field with the provided initial value.
|
PropertyField(java.lang.String initialValue,
boolean isReadWrite)
Constructs a PropertyField as a text field with the provided initial value, either writeable or not.
|
PropertyField(java.lang.String label,
java.lang.String initialValue)
Constructs a labelled PropertyField as a writeable text field with the provided initial value.
|
PropertyField(java.lang.String label,
java.lang.String initialValue,
boolean isReadWrite)
Constructs a labelled PropertyField as a text field with the provided initial value, either writeable or not.
|
PropertyField(java.lang.String label,
java.lang.String initialValue,
boolean isReadWrite,
java.lang.Object domain,
int show)
Constructs a PropertyField with an optional label, an initial value, a "writeable" flag, an optional domain
(for the slider and list options), and a display form (checkboxes, view buttons, text fields, sliders, or lists).
|
Modifier and Type | Method and Description |
---|---|
java.awt.Color |
getEditedColor() |
javax.swing.JTextField |
getField() |
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 |
setEnabled(boolean b) |
void |
setToolTipText(java.lang.String text) |
void |
setValue(java.lang.String val)
Sets the value, not filtering it through newValue(val) first.
|
void |
submit()
Commits to the current setting of the propertyField, filtering it through newValue.
|
void |
update()
Reverts the property field to its previous string value WITHOUT calling newValue()
|
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.
|
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, 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, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
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, setLayout, transferFocusDownCycle, validate, validateTree
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, getAccessibleContext, 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, 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, transferFocusBackward, transferFocusUpCycle
public static final int SHOW_CHECKBOX
public static final int SHOW_TEXTFIELD
public static final int SHOW_VIEWBUTTON
public static final int SHOW_SLIDER
public static final int SHOW_LIST
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, java.lang.Object domain, int show)
public javax.swing.JTextField getField()
public void setEditedColor(java.awt.Color c)
public java.awt.Color getEditedColor()
public void submit()
public void update()
public void setValue(java.lang.String val)
public java.lang.String getValue()
public java.lang.String newValue(java.lang.String newValue)
public void viewProperty()
public void setToolTipText(java.lang.String text)
setToolTipText
in class javax.swing.JComponent
public java.awt.Dimension getMinimumSize()
getMinimumSize
in class javax.swing.JComponent
public java.awt.Dimension getPreferredSize()
getPreferredSize
in class javax.swing.JComponent
public void setEnabled(boolean b)
setEnabled
in class javax.swing.JComponent