Diamond Control Suite 3.0

diamondedge.swing
Class DsLabel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by diamondedge.swing.DsLabel
All Implemented Interfaces:
DsConstants, ImageObserver, MenuContainer, Serializable, SwingConstants
Direct Known Subclasses:
DsCellRenderer

public class DsLabel
extends JComponent
implements DsConstants

DsLabel displays multiple lines of text and/or an icon that a user can't change directly. It is a replacement to and uses the same API as JLabel. It breaks the text up into multiple lines when WordWrap is turned on. Many other additional features are available such as rotation, margins, text styles (3D and highlighting), built-in borders, and font underlining and strikethrough.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 
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 diamondedge.swing.DsConstants
ACCOUNTING, ALL, ASCENDING, ASCENDING_CASE, BORDER_BOTTOM, BORDER_LEFT, BORDER_NONE, BORDER_OUTLINE, BORDER_RIGHT, BORDER_TOP, CROSS_LINES, DASH, DASH_DOT, DASH_DOT_DOT, DEFAULT, DESCENDING, DESCENDING_CASE, DIAGONAL_CROSS_LINES, DOT, DOUBLE, DOUBLE_LINE, DOWNWARD_DIAGONAL_LINES, ETCHED, ETCHED_RAISED, FALSE, FIND_ALL, FIND_EQUALS, FIND_GT, FIND_GTE, FIND_LT, FIND_LTE, FIND_NE, FIND_PREFIX, FIND_REGEX, FIND_STRING, FIRST, FLAT, GRID_DASH, GRID_DASH_DOT, GRID_DASH_DOT_DOT, GRID_DOT, GRID_LINE, HIGHLIGHT_SELECTION_ALWAYS, HIGHLIGHT_SELECTION_NEVER, HIGHLIGHT_SELECTION_WITH_FOCUS, HORIZONTAL_LINES, LOWERED, LOWERED_LIGHT, NONE, RAISED, RAISED_LIGHT, SELECT_CELL, SELECT_NONE, SELECT_ROW, SINGLE, SINGLE_LINE, SOLID, STRETCH, TILE, TRANSPARENT, TRUE, UPWARD_DIAGONAL_LINES, VERTICAL_LINES
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
DsLabel()
          Creates a DsLabel without an icon and a blank string for the text.
DsLabel(Icon icon)
          Creates a DsLabel with an icon which is centered vertically and horizontally.
DsLabel(Icon icon, int horizontalAlignment)
          Creates a DsLabel with an icon which is centered vertically and the specified horizontal alignment.
DsLabel(String text)
          Creates a DsLabel with the specified text and without an icon.
DsLabel(String text, Icon icon, int horizontalAlignment)
          Creates a DsLabel with the specified text, icon and horizontal alignment.
DsLabel(String text, int horizontalAlignment)
           
 
Method Summary
 void addTextListener(TextListener l)
          Adds the specified text listener to receive text events
protected  Border createBorder()
           
protected  void fireLabelChangedEvent()
          Fire an text event to the listeners
 Paint getBackgroundPaint()
           
 int getCenterBorder()
          Returns whether to draw a border in between the InnerBorder and the OuterBorder.
 Icon getDisabledIcon()
          Returns the graphic image (glyph, icon) that the label displays when the label is disabled.
 char getDisplayedMnemonic()
          Returns the character that indicates a mnemonic key.
 int getFontUnderline()
          Returns a value that determines how the text for the label is underlined.
 Paint getForegroundPaint()
           
 int getHorizontalAlignment()
          Returns the horizontal alignment of the contents (text and icon) within the Label
 int getHorizontalTextPosition()
          Returns the horizontal position of the text relative to the icon
 Icon getIcon()
          Returns the graphic image (glyph, icon) that the label displays.
 int getIconTextGap()
          Returns the amount of space between the text and the icon displayed in this label.
 int getInnerBorder()
          Returns whether to draw a border inside of the CenterBorder.
 Insets getInsets()
          Returns the insets which includes the border's insets and the margin.
 Insets getInsets(Insets insets)
          Returns the insets which includes the border's insets and the margin.
 Component getLabelFor()
          Get the component this is labelling.
 Color getLineBorderColor()
          Returns the color used to draw the line border.
 int getLineBorderWidth()
          Returns the width of the line border drawn around the label.
 Insets getMargins()
          Returns the spacing between the border and the contents (text/icon).
 Dimension getMinimumSize()
          This method is called when the layout manager wants to know the bare minimum amount of space we need to get by.
 int getOuterBorder()
          Returns whether to draw a border on the outside of the label but inside of the outline if it exists.
 Dimension getPreferredSize()
          This method is called by a layout manager when it wants to know how big we'd like to be.
 int getRotation()
          Returns the degrees to rotate text and icon.
 String getText()
          Returns the text that the label displays
 Color getTextOutlineColor()
          Returns the color used to draw an outline around each character of the text.
 double getTextOutlineWidth()
          Returns the width of the outline drawn around each character in the text.
 int getTextStyle()
          Returns a value that determines how the text is drawn.
 int getVerticalAlignment()
          Returns the vertical alignment of the contents (text and icon) within the Label
 int getVerticalTextPosition()
          Returns the vertical position of the text relative to the icon
 boolean isAutoSize()
          Returns a value that determines whether the label is automatically resized to display its entire contents.
 boolean isFontStrikeThrough()
          Returns a value that determines whether the text for the label is displayed with a line through the text.
 boolean isWordWrap()
          Returns a value that determines whether the text should be wrapped to a new line when it reaches the trailing margin.
protected  void paintComponent(Graphics g)
           
 void removeTextListener(TextListener l)
          Removes the specified text listener so it no longer receives text events.
 void setAutoSize(boolean s)
          Sets a value that determines whether the label is automatically resized to display its entire contents.
 void setBackground(Color c)
           
 void setBackgroundPaint(Paint p)
           
protected  void setBorders()
           
 void setBounds(int x, int y, int width, int height)
          Moves and resizes this component.
 void setCenterBorder(int val)
          Creates a border in between the InnerBorder and the OuterBorder.
 void setDisabledIcon(Icon icon)
          Defines the icon this component will display when the label is disabled.
 void setDisplayedMnemonic(char mnemonicChar)
          Specify a character that indicates a mnemonic key.
 void setFont(Font f)
           
 void setFontStrikeThrough(boolean strikeThrough)
          Sets a value that determines whether the text for the label is displayed with a line through the text.
 void setFontUnderline(int underline)
          Sets a value that determines how the text for the label is underlined.
 void setForeground(Color c)
          Sets the text color (ForegroundPaint property).
 void setForegroundPaint(Paint p)
           
 void setHorizontalAlignment(int align)
          Sets the horizontal alignment of the contents (text and icon) within the Label.
 void setHorizontalTextPosition(int textPosition)
          Sets the horizontal position of the text relative to the icon.
 void setIcon(Icon icon)
          Defines the icon this component will display.
 void setIconTextGap(int iconTextGap)
          If both the icon and text properties are set, this property defines the space between them.
 void setInnerBorder(int val)
          Creates a border on the inside of the CenterBorder.
 void setLabelFor(Component c)
          Specify the component on which the label will call the requestFocus method when the mnemonic is activated.
 void setLineBorderColor(Color c)
          Sets the color used to draw the line border.
 void setLineBorderWidth(int lineWidth)
          Sets the width of the line border drawn around the label.
 void setMargins(Insets margins)
          Sets the spacing between the border and the contents (text/icon).
 void setOuterBorder(int val)
          Creates a border on the outside of the label but inside of the outline if it exists.
 void setRotation(int val)
          Set the degrees to rotate the text and icon.
 void setText(String text)
          Sets the text that the label displays.
 void setTextOutlineColor(Color c)
          Sets the color used to draw an outline around each character of the text.
 void setTextOutlineWidth(double lineWidth)
          Sets the width of the outline drawn around each character in the text.
 void setTextStyle(int style)
          Sets a value that determines how the text is drawn.
 void setVerticalAlignment(int a)
          Sets the vertical alignment of the contents (text and icon) within the Label.
 void setVerticalTextPosition(int textPosition)
          Sets the vertical position of the text relative to the icon.
 void setWordWrap(boolean s)
          Sets a value that determines whether the text should be wrapped to a new line when it reaches the trailing margin.
 void updateUI()
           
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getListeners, getLocation, getMaximumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, 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, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
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, 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, firePropertyChange, 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, hide, 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, 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
 

Constructor Detail

DsLabel

public DsLabel(String text,
               Icon icon,
               int horizontalAlignment)
Creates a DsLabel with the specified text, icon and horizontal alignment. The contents are centered vertically. The text is on the trailing side of the icon.

Parameters:
text - The text displayed in the label.
icon - The icon displayed next to the text.
horizontalAlignment - The horizontal alignment of the contents (text and icon) within the Label. One of: LEFT, CENTER, RIGHT, LEADING or TRAILING

DsLabel

public DsLabel(String text)
Creates a DsLabel with the specified text and without an icon. The text is aligned to the leading edge horizontally and centered vertically.


DsLabel

public DsLabel(String text,
               int horizontalAlignment)

DsLabel

public DsLabel(Icon icon)
Creates a DsLabel with an icon which is centered vertically and horizontally.


DsLabel

public DsLabel(Icon icon,
               int horizontalAlignment)
Creates a DsLabel with an icon which is centered vertically and the specified horizontal alignment.

Parameters:
horizontalAlignment - - One of: LEFT, CENTER, RIGHT, LEADING or TRAILING

DsLabel

public DsLabel()
Creates a DsLabel without an icon and a blank string for the text.

Method Detail

updateUI

public void updateUI()
Overrides:
updateUI in class JComponent

setForeground

public void setForeground(Color c)
Sets the text color (ForegroundPaint property).

Overrides:
setForeground in class JComponent

getForegroundPaint

public Paint getForegroundPaint()

setForegroundPaint

public void setForegroundPaint(Paint p)

setBackground

public void setBackground(Color c)
Overrides:
setBackground in class JComponent

getBackgroundPaint

public Paint getBackgroundPaint()

setBackgroundPaint

public void setBackgroundPaint(Paint p)

isAutoSize

public boolean isAutoSize()
Returns a value that determines whether the label is automatically resized to display its entire contents.


setAutoSize

public void setAutoSize(boolean s)
Sets a value that determines whether the label is automatically resized to display its entire contents.


isWordWrap

public boolean isWordWrap()
Returns a value that determines whether the text should be wrapped to a new line when it reaches the trailing margin.


setWordWrap

public void setWordWrap(boolean s)
Sets a value that