Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.javathis.utilities.ui
Class JTLabel  view JTLabel download JTLabel.java

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JLabel
                  extended bycom.javathis.utilities.ui.JTLabel
All Implemented Interfaces:
javax.accessibility.Accessible, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.beans.PropertyChangeListener, java.io.Serializable, javax.swing.SwingConstants

public class JTLabel
extends javax.swing.JLabel
implements java.beans.PropertyChangeListener

A JTLabel is a label that can provide a visual que that the component that it is labeling is required.

The default required character is a red asterick. The color and character are customizable.


Nested Class Summary
 
Nested classes inherited from class javax.swing.JLabel
javax.swing.JLabel.AccessibleJLabel
 
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
private static char DEFAULT_REQUIRED_CHARACTER
           
private static java.awt.Color DEFAULT_REQUIRED_COLOR
           
private  boolean isInit
           
private  boolean isRequired
           
private static char REQUIRED_CHARACTER
           
private static java.awt.Color REQUIRED_COLOR
           
private  java.lang.String unmodifiedText
           
private static java.util.Vector UPDATE_LABEL_LISTENERS
           
 
Fields inherited from class javax.swing.JLabel
labelFor
 
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.Container
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
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
JTLabel()
          Creates a JTLabel instance with no image and with an empty string for the title.
JTLabel(javax.swing.Icon image)
          Creates a JTLabel instance with the specified image.
JTLabel(javax.swing.Icon image, int horizontalAlignment)
          Creates a JTLabel instance with the specified image and horizontal alignment.
JTLabel(java.lang.String text)
          Creates a JTLabel instance with the specified text.
JTLabel(java.lang.String text, javax.swing.Icon icon, int horizontalAlignment)
          Creates a JTLabel instance with the specified text, image, and horizontal alignment.
JTLabel(java.lang.String text, int horizontalAlignment)
          Creates a JTLabel instance with the specified text and horizontal alignment.
 
Method Summary
 void destroy()
          Automaticly called if GC calls finalize method.
protected  void finalize()
          Called by the garbage collector when it determines that there are no more references to this object.
 char getRequiredCharacter()
           
static java.awt.Color getRequiredColor()
           
 java.lang.String getText()
          Returns the text string that the label displays.
 boolean isRequired()
           
 void jtInit()
          Automaticly called at construction.
 void propertyChange(java.beans.PropertyChangeEvent e)
          Fired after a Bean's property has changed.
 void setRequired(boolean isRequired)
          Marks the label as required or not, and updates it accordingly.
 void setRequiredCharacter(java.lang.Character requiredCharacter)
          Provide the Character to use for signifying the component/field the label is for as a required component.
 void setRequiredColor(java.awt.Color requiredColor)
          Provide the Color to use for the required character.
 void setText(java.lang.String text)
          Defines the single line of text this component will display.
protected  void updateLabel()
          Called internnally to notify the JTLabel that it's contents have changed, and needs to be updated.
 
Methods inherited from class javax.swing.JLabel
checkHorizontalKey, checkVerticalKey, getAccessibleContext, getDisabledIcon, getDisplayedMnemonic, getDisplayedMnemonicIndex, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextGap, getLabelFor, getUI, getUIClassID, getVerticalAlignment, getVerticalTextPosition, imageUpdate, paramString, setDisabledIcon, setDisplayedMnemonic, setDisplayedMnemonic, setDisplayedMnemonicIndex, setFont, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabelFor, setUI, setVerticalAlignment, setVerticalTextPosition, updateUI
 
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, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, 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, setForeground, 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, 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, swapComponents, 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, 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, transferFocusBackward, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_REQUIRED_CHARACTER

private static final char DEFAULT_REQUIRED_CHARACTER
See Also:
Constant Field Values

DEFAULT_REQUIRED_COLOR

private static final java.awt.Color DEFAULT_REQUIRED_COLOR

REQUIRED_CHARACTER

private static char REQUIRED_CHARACTER

REQUIRED_COLOR

private static java.awt.Color REQUIRED_COLOR

UPDATE_LABEL_LISTENERS

private static java.util.Vector UPDATE_LABEL_LISTENERS

isRequired

private boolean isRequired

isInit

private boolean isInit

unmodifiedText

private java.lang.String unmodifiedText
Constructor Detail

JTLabel

public JTLabel()
Creates a JTLabel instance with no image and with an empty string for the title. The label is centered vertically in its display area. The label's contents, once set, will be displayed on the leading edge of the label's display area.


JTLabel

public JTLabel(javax.swing.Icon image)
Creates a JTLabel instance with the specified image. The label is centered vertically and horizontally in its display area.


JTLabel

public JTLabel(javax.swing.Icon image,
               int horizontalAlignment)
Creates a JTLabel instance with the specified image and horizontal alignment. The label is centered vertically in its display area.


JTLabel

public JTLabel(java.lang.String text)
Creates a JTLabel instance with the specified text. The label is aligned against the leading edge of its display area, and centered vertically.


JTLabel

public JTLabel(java.lang.String text,
               int horizontalAlignment)
Creates a JTLabel instance with the specified text and horizontal alignment. The label is centered vertically in its display area.


JTLabel

public JTLabel(java.lang.String text,
               javax.swing.Icon icon,
               int horizontalAlignment)
Creates a JTLabel instance with the specified text, image, and horizontal alignment. The label is centered vertically in its display area. The text is on the trailing edge of the image.

Method Detail

jtInit

public void jtInit()
Automaticly called at construction. Can be called manually if you need to re-Init this component after it has been destroyed. However, once it has been GC'd there is no guarantee as to what will happen.


destroy

public void destroy()
Automaticly called if GC calls finalize method. However, this is not guaranteed, and if this component causes a memory leak, it may need to be called manually, when needed.


setText

public void setText(java.lang.String text)
Defines the single line of text this component will display. If the value of text is null or empty string, nothing is displayed.

The default value of this property is null.


getText

public java.lang.String getText()
Returns the text string that the label displays. Always without the required character.


setRequiredCharacter

public void setRequiredCharacter(java.lang.Character requiredCharacter)
Provide the Character to use for signifying the component/field the label is for as a required component. The default is an asterick(*).

Note:

That all JTLabel's use the same character, therefore this method only needs to be called once to change it for all BTLabels. If a null Character is provided then it will reset the required character back to the default.


getRequiredCharacter

public char getRequiredCharacter()

setRequiredColor

public void setRequiredColor(java.awt.Color requiredColor)
Provide the Color to use for the required character. The default is red.

Note:

That all JTLabel's use the same color, therefore this method only needs to be called once to change it for all BTLabels. If a null Color is provided then it will reset the required color back to the default.


getRequiredColor

public static java.awt.Color getRequiredColor()

updateLabel

protected void updateLabel()
Called internnally to notify the JTLabel that it's contents have changed, and needs to be updated.

Note: Should not normally be called from an external source.


setRequired

public void setRequired(boolean isRequired)
Marks the label as required or not, and updates it accordingly.


isRequired

public boolean isRequired()

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent e)
Description copied from interface: java.beans.PropertyChangeListener
Fired after a Bean's property has changed.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener

finalize

protected void finalize()
                 throws java.lang.Throwable
Called by the garbage collector when it determines that there are no more references to this object. Overrided to dispose of system resources and to perform cleanup on this object.