de.matthiasmann.twl
Class Label

java.lang.Object
  extended by de.matthiasmann.twl.Widget
      extended by de.matthiasmann.twl.TextWidget
          extended by de.matthiasmann.twl.Label
Direct Known Subclasses:
DatePickerComboBox.ComboboxLabel, FPSCounter, WheelWidget.StringItemRenderer

public class Label
extends TextWidget

A label widget.


Nested Class Summary
static class Label.CallbackReason
           
 
Nested classes/interfaces inherited from class de.matthiasmann.twl.Widget
Widget.OffscreenMouseAdjustments, Widget.RenderOffscreen
 
Field Summary
 
Fields inherited from class de.matthiasmann.twl.TextWidget
STATE_HOVER, STATE_TEXT_CHANGED, STATE_TEXT_SELECTION
 
Fields inherited from class de.matthiasmann.twl.Widget
STATE_DISABLED, STATE_HAS_FOCUSED_CHILD, STATE_HAS_OPEN_POPUPS, STATE_KEYBOARD_FOCUS
 
Constructor Summary
Label()
           
Label(AnimationState animState)
          Creates a Label with a shared animation state
Label(AnimationState animState, boolean inherit)
          Creates a Label with a shared or inherited animation state
Label(java.lang.String text)
           
 
Method Summary
 void addCallback(CallbackWithReason<Label.CallbackReason> cb)
           
protected  void applyTheme(ThemeInfo themeInfo)
          Apply the given theme.
protected  void applyThemeLabel(ThemeInfo themeInfo)
           
protected  void doCallback(Label.CallbackReason reason)
           
 Widget getLabelFor()
           
 int getMinHeight()
          Returns the minimum height of the widget.
 int getMinWidth()
          Returns the minimum width of the widget.
 java.lang.String getText()
           
 java.lang.Object getTooltipContent()
          Returns the currently set tooltip content.
protected  void handleClick(boolean doubleClick)
           
protected  boolean handleEvent(Event evt)
          Called when an event occurred that this widget could be interested in.
 boolean isAutoSize()
           
 void removeCallback(CallbackWithReason<Label.CallbackReason> cb)
           
 boolean requestKeyboardFocus()
          Requests that the keyboard focus is transfered to this widget.
 void setAutoSize(boolean autoSize)
           
 void setFont(Font font)
           
 void setLabelFor(Widget labelFor)
          Sets the associated widget for this label.
 void setText(java.lang.String text)
           
 
Methods inherited from class de.matthiasmann.twl.TextWidget
applyThemeTextWidget, computeRelativeCursorPositionX, computeRelativeCursorPositionX, computeTextHeight, computeTextWidth, computeTextX, computeTextY, destroy, getAlignment, getCharSequence, getFont, getNumTextLines, getPreferredInnerHeight, getPreferredInnerWidth, handleMouseHover, hasText, isCache, isMultilineText, paintLabelText, paintTextAt, paintWidget, paintWithSelection, paintWithSelection, setAlignment, setCache, setCharSequence
 
Methods inherited from class de.matthiasmann.twl.Widget
add, addActionMapping, addPropertyChangeListener, addPropertyChangeListener, adjustSize, afterAddToGUI, allChildrenRemoved, applyThemeBackground, applyThemeBorder, applyThemeInputMap, applyThemeMaxSize, applyThemeMinSize, applyThemeMouseCursor, applyThemeOffscreenExtra, applyThemeOverlay, applyThemeTooltip, beforeRemoveFromGUI, borderChanged, canAcceptKeyboardFocus, childAdded, childInvalidateLayout, childRemoved, childVisibilityChanged, computeSize, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, focusFirstChild, focusLastChild, focusNextChild, focusPrevChild, getActionMap, getAnimationState, getBackground, getBorderBottom, getBorderHorizontal, getBorderLeft, getBorderRight, getBorderTop, getBorderVertical, getBottom, getChild, getChildAt, getChildIndex, getGUI, getHeight, getInnerBottom, getInnerHeight, getInnerRight, getInnerWidth, getInnerX, getInnerY, getInputMap, getKeyboardFocusOrder, getMaxHeight, getMaxWidth, getMouseCursor, getMouseCursor, getNumChildren, getOffscreenExtraBottom, getOffscreenExtraLeft, getOffscreenExtraRight, getOffscreenExtraTop, getOrCreateActionMap, getOverlay, getParent, getPreferredHeight, getPreferredWidth, getRenderOffscreen, getRight, getRootWidget, getTheme, getThemePath, getThemeTooltipContent, getTintAnimator, getTooltipContentAt, getWidgetAt, getWidth, getX, getY, giveupKeyboardFocus, handleKeyStrokeAction, hasKeyboardFocus, hasOpenPopups, hasSharedAnimationState, insertChild, invalidateLayout, invalidateLayoutLocally, isAbsoluteTheme, isClip, isDepthFocusTraversal, isEnabled, isFocusKeyEnabled, isInside, isLocallyEnabled, isMouseInside, isVisible, keyboardFocusChildChanged, keyboardFocusGained, keyboardFocusGained, keyboardFocusLost, layout, layoutChildFullInnerArea, layoutChildrenFullInnerArea, moveChild, paint, paintBackground, paintChild, paintChildren, paintDragOverlay, paintOverlay, positionChanged, reapplyTheme, removeAllChildren, removeChild, removeChild, removePropertyChangeListener, removePropertyChangeListener, requestKeyboardFocus, resetTooltip, setActionMap, setBackground, setBorderSize, setBorderSize, setBorderSize, setBorderSize, setCanAcceptKeyboardFocus, setClip, setDepthFocusTraversal, setEnabled, setFocusKeyEnabled, setInnerSize, setInputMap, setMaxSize, setMinSize, setMouseCursor, setOffscreenExtra, setOffscreenExtra, setOverlay, setPosition, setRenderOffscreen, setSize, setTheme, setTintAnimator, setTooltipContent, setVisible, sizeChanged, updateTintAnimation, updateTooltip, validateLayout, widgetDisabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Label

public Label()

Label

public Label(AnimationState animState)
Creates a Label with a shared animation state

Parameters:
animState - the animation state to share, can be null

Label

public Label(AnimationState animState,
             boolean inherit)
Creates a Label with a shared or inherited animation state

Parameters:
animState - the animation state to share or inherit, can be null
inherit - true if the animation state should be inherited false for sharing

Label

public Label(java.lang.String text)
Method Detail

addCallback

public void addCallback(CallbackWithReason<Label.CallbackReason> cb)

removeCallback

public void removeCallback(CallbackWithReason<Label.CallbackReason> cb)

doCallback

protected void doCallback(Label.CallbackReason reason)

isAutoSize

public boolean isAutoSize()

setAutoSize

public void setAutoSize(boolean autoSize)

setFont

public void setFont(Font font)
Overrides:
setFont in class TextWidget

getText

public java.lang.String getText()

setText

public void setText(java.lang.String text)

getTooltipContent

public java.lang.Object getTooltipContent()
Description copied from class: Widget
Returns the currently set tooltip content.

Overrides:
getTooltipContent in class Widget
Returns:
the currently set tooltip content. Can be null.

getLabelFor

public Widget getLabelFor()

setLabelFor

public void setLabelFor(Widget labelFor)
Sets the associated widget for this label. This will cause the label to get it's tooltip content from the associated widget and also forward the keyboard focus to it.

Parameters:
labelFor - the associated widget. Can be null.

applyThemeLabel

protected void applyThemeLabel(ThemeInfo themeInfo)

applyTheme

protected void applyTheme(ThemeInfo themeInfo)
Description copied from class: Widget
Apply the given theme. This method also calls invalidateLayout()

Overrides:
applyTheme in class TextWidget
Parameters:
themeInfo - The theme info for this widget

requestKeyboardFocus

public boolean requestKeyboardFocus()
Description copied from class: Widget
Requests that the keyboard focus is transfered to this widget.

Use with care - users don't expect focus changes while working with the UI

Focus transfer only works when the widget is added to the GUI tree. See Widget.getGUI().

Overrides:
requestKeyboardFocus in class Widget
Returns:
true if keyboard focus was transfered to this widget.

getMinWidth

public int getMinWidth()
Description copied from class: Widget
Returns the minimum width of the widget. Layout manager will allocate atleast the minimum width to a widget even when the container is not big enough. The default implementation will not return values smaller then the current border width.

Overrides:
getMinWidth in class Widget
Returns:
the minimum width of the widget

getMinHeight

public int getMinHeight()
Description copied from class: Widget
Returns the minimum height of the widget. Layout manager will allocate atleast the minimum height to a widget even when the container is not big enough. The default implementation will not return values smaller then the current border width.

Overrides:
getMinHeight in class Widget
Returns:
the minimum height of the widget

handleEvent

protected boolean handleEvent(Event evt)
Description copied from class: Widget
Called when an event occurred that this widget could be interested in.

The default implementation handles only keyboard events and delegates them to the child widget which has keyboard focus. If focusKey handling is enabled then this widget cycles the keyboard focus through it's children. If the key was not consumed by a child or focusKey and an inputMap is specified then the event is translated by the InputMap and handleKeyStrokeAction is called when a mapping was found.

If the widget wants to receive mouse events then it must return true for all mouse events except for MOUSE_WHEEL (which is optional) event. Otherwise the following mouse event are not send. Before mouse movement or button events are send a MOUSE_ENTERED event is send first.

Overrides:
handleEvent in class Widget
Parameters:
evt - The event - do not store this object - it may be reused
Returns:
true if the widget handled this event
See Also:
Widget.setFocusKeyEnabled(boolean), Widget.handleKeyStrokeAction(java.lang.String, de.matthiasmann.twl.Event), Widget.setInputMap(de.matthiasmann.twl.InputMap)

handleClick

protected void handleClick(boolean doubleClick)