public abstract class LabeledControl extends LabeledComponent
ValueChangeListeners
, which
are fired every time the value associated with this control changes. Values
can be set externally (outside of the GUI) by calling #setValue.
Values for a LabeledControl can be set either through the GUI or by calling
setValue
. All controls should be able to support a special
``void'' value identified by
Property.VoidValue
, which can
be used to indicate undefined or unspecified values. Void values are
typically not enabled by default but can be enabled by calling
setVoidValueEnabled
. If enabled, a void value
can be set by calling
setValue (Property.VoidValue);Some individual controls may also allow a void value to be set through the GUI. In this case,
getGUIVoidEnabled
will return
true
.
Some controls may accept null
as a valid value. In this case,
getNullValueEnabled
will return
true
. null
is not used to indicate void values
because in some situations it may be a proper value in its own right.
The current value of a control can be read back using getValue
. If void values are enabled, the user should check that the value
is not Property.VoidValue
before casting it to a type specific to the control.
An application can add value change listeners that are called whenever the
value of the control changes. Firing occurs only when there is a change a
value, not just when a value is set. An application can also add value check
listeners that are called to check any prospective new value. These listeners
can declare a value to be invalid, or correct it to an adjusted value.
In general, setting a new value entails:
validateValue
, updateValue
, and
updateDisplay
.myProps
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Constructor and Description |
---|
LabeledControl(java.lang.String labelText)
Creates a control with specified label text.
|
LabeledControl(java.lang.String labelText,
java.awt.Component comp)
Creates a control with specified label text and a major component.
|
Modifier and Type | Method and Description |
---|---|
void |
addValueChangeListener(ValueChangeListener l)
Adds a ValueChangeListener to this control.
|
void |
addValueCheckListener(ValueCheckListener l)
Adds a ValueCheckListener to this control.
|
void |
clearValueChangeListeners()
Remove all ValueChangeListeners from this control.
|
void |
dispose()
Releases all the resources held by this control.
|
boolean |
getGUIVoidEnabled()
Returns true if void values can be set from the GUI.
|
boolean |
getNullValueEnabled()
Returns true if null values are enabled for this control.
|
java.lang.Object |
getValue() |
ValueChangeListener[] |
getValueChangeListeners()
Returns a list of all the ValueChangeListeners currently held by this
control.
|
ValueCheckListener[] |
getValueCheckListeners()
Returns a list of all the ValueCheckListeners currently held by this
control.
|
boolean |
getVoidValueEnabled()
Returns true if void values are enabled for this control.
|
boolean |
isEnabledAll()
Returns true if this control, and all its components, are enabled.
|
void |
maskValueChangeListeners(boolean masked)
Enables or disables the value change listeners.
|
void |
maskValueChecks(boolean masked)
Enables or disables value checking from within
setValue . |
void |
removeValueChangeListener(ValueChangeListener l)
Removes a ValueChangeListener from this control.
|
void |
setBackgroundAll(java.awt.Color color)
Sets the background of this control and all its subcomponents, except for
JTextFields, where setting the background would obscure the text field.
|
void |
setEnabledAll(boolean enable)
Enables or disables this control by enabling or disabling all its
components.
|
void |
setValue(java.lang.Object value)
Sets a new value for this control.
|
void |
setVoidValueEnabled(boolean enable)
Enables void values to be set for this control.
|
boolean |
valueChangeListenersMasked()
Returns true if the value change listeners are masked.
|
boolean |
valueChecksMasked()
Returns true if value checking is enabled within
setValue . |
boolean |
valueIsNull()
Returns true if the current value for this control is null.
|
boolean |
valueIsVoid()
Returns true if the current value for this control is void (i.e.,
Property.VoidValue ). |
actionPerformed, addMajorComponent, addMajorComponent, getActions, getAllPropertyInfo, getLabel, getLabelSpacing, getMainComponent, getMajorComponent, getMaximumSize, getMinimumSize, getPreferredLabelSpacing, getSpacing, indexOfMajor, isLabelStretchable, isStretchable, numMajorComponents, removeMajorComponent, setLabelSpacing, setLabelStretchable, setLabelText, setSpacing, setStretchable
getBackgroundColor, getLabelFontColor, getLabelText, getLeftInset, getProperty, isScanning, isSelected, setBackgroundColor, setLabelFontColor, setLabelFontColor, setScanning, setSelected
getAccessibleContext, getUI, getUIClassID, setUI, updateUI
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
add, add, add, add, add, addContainerListener, 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, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, 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, 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, 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
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
getToolTipText, setToolTipText
public LabeledControl(java.lang.String labelText)
labelText
- text value for the control labelpublic LabeledControl(java.lang.String labelText, java.awt.Component comp)
labelText
- text value for the control labelcomp
- major component to add to this controlpublic void maskValueChangeListeners(boolean masked)
fireValueChangeListeners
will do
nothing.masked
- if true, masks the value change listeners.public boolean valueChangeListenersMasked()
public void maskValueChecks(boolean masked)
setValue
.masked
- if true, masks value checking.public boolean valueChecksMasked()
setValue
.public void addValueChangeListener(ValueChangeListener l)
l
- listener to addpublic void removeValueChangeListener(ValueChangeListener l)
l
- listener to removepublic void clearValueChangeListeners()
public ValueChangeListener[] getValueChangeListeners()
public void addValueCheckListener(ValueCheckListener l)
l
- listener to addpublic ValueCheckListener[] getValueCheckListeners()
public void dispose()
dispose
in interface Disposable
dispose
in class LabeledComponent
public void setEnabledAll(boolean enable)
enable
- enables or disables all componentspublic void setBackgroundAll(java.awt.Color color)
color
- new background colorpublic boolean isEnabledAll()
public boolean getGUIVoidEnabled()
public void setVoidValueEnabled(boolean enable)
false
.enable
- enables or disables void values for this controlpublic boolean getVoidValueEnabled()
public boolean getNullValueEnabled()
public java.lang.Object getValue()
public boolean valueIsVoid()
Property.VoidValue
).public boolean valueIsNull()
public void setValue(java.lang.Object value)
value
- new value for this control