public class DisplayLabel extends Label implements Computable
The values displayed in a DisplayLabel are recomputed when the Label's compute() method is called. Usually, this is done by a Controller that the DisplayLabel is registered with. See the Controller class for more information.
Label.AccessibleAWTLabelComponent.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy| Modifier and Type | Field and Description |
|---|---|
protected int |
numSize
Desired maximum number of characters in displayed numbers.
|
protected String |
text
Unsubstituted text for display.
|
protected Value[] |
values
Value objects whose values will be
substituted for #'s in text.
|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH| Constructor and Description |
|---|
DisplayLabel()
Create a label with no expressions set up to display a
single number.
|
DisplayLabel(String text,
Value val)
Convenience method for making a DisplayLabel with just one value to display.
|
DisplayLabel(String text,
Value[] vals)
Create a DisplayLabel to display one or more values.
|
| Modifier and Type | Method and Description |
|---|---|
void |
compute()
The compute method recalculates the displayed Values
and changes the text of the label to show the new values.
|
String |
getBaseText()
Return the basic text, including the #'s where Values
are inserted in the displayed text.
|
int |
getNumSize()
Return the desired maximum number of characters in displayed numbers.
|
Dimension |
getPreferredSize()
Return the preferred size of this DisplayLabel.
|
Value[] |
getValues()
Get the array of Value objects whose values are displayed
in this DisplayLabel.
|
void |
setNumSize(int size)
Set the desired maximum number of characters in displayed numbers.
|
void |
setText(String text)
Set text for display -- text should include as many (single) #'s
as there are values to display.
|
void |
setValue(Value val)
A convenience method that can be used when the display string contains
just a single #.
|
void |
setValues(Value[] vals)
Set the array of Value objects whose values are displayed
in this DisplayLabel, and change the display to show
the new values.
|
addNotify, getAccessibleContext, getAlignment, getText, paramString, setAlignmentaction, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, revalidate, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validateprotected String text
protected int numSize
protected Value[] values
public DisplayLabel()
public DisplayLabel(String text, Value val)
text - Text to display. It shoud contain a single '#', which will be substituted by the value.val - a Value object whose value is substituted for the # in the text.public DisplayLabel(String text, Value[] vals)
text - The text to display. If this is null, it is set to "#".vals - The Value object(s) whose values are substituted for #'s in the text. If this is null,
the values shoud be set later by calling the setValues() method.public void compute()
compute in interface Computablepublic Value[] getValues()
public void setValue(Value val)
public void setValues(Value[] vals)
public void setNumSize(int size)
public int getNumSize()
public String getBaseText()
public void setText(String text)
public Dimension getPreferredSize()
getPreferredSize in class Component