com.jmex.bui
Class BLabel

java.lang.Object
  extended by com.jmex.bui.BComponent
      extended by com.jmex.bui.BTextComponent
          extended by com.jmex.bui.BLabel
All Implemented Interfaces:
BConstants
Direct Known Subclasses:
BButton, BComboBox, BMenuItem

public class BLabel
extends BTextComponent
implements BConstants

A simple component for displaying a textual label.


Nested Class Summary
static class BLabel.Fit
          Configures the label's strategy when it does not fit into its allocated space.
 
Field Summary
protected  Label _label
           
 
Fields inherited from class com.jmex.bui.BTextComponent
_effcols, _effsizes, _haligns, _lineSpacings, _teffects, _textfacts, _valigns
 
Fields inherited from class com.jmex.bui.BComponent
_alpha, _backgrounds, _bbuf, _borders, _colors, _cursor, _enabled, _height, _hover, _insets, _listeners, _parent, _preferredSize, _properties, _styleClass, _tipmouse, _tipStyle, _tiptext, _valid, _visible, _width, _x, _y, DEFAULT, DISABLED, HOVER, STATE_COUNT, STATE_PCLASSES
 
Fields inherited from interface com.jmex.bui.BConstants
BOTTOM, CENTER, DEFAULT_SIZE, DEFAULT_SPACING, GLOW, HORIZONTAL, LEFT, NORMAL, OUTLINE, OVERLAPPING, PLAIN, RIGHT, SHADOW, TOP, VERTICAL
 
Constructor Summary
BLabel(BIcon icon)
          Creates a label that will display the supplied icon.
BLabel(BIcon icon, String styleClass)
          Creates a label that will display the supplied icon using the specified style class.
BLabel(BIcon icon, String text, String styleClass)
          Creates a label that will display the supplied text and icon using the specified style class.
BLabel(String text)
          Creates a label that will display the supplied text.
BLabel(String text, String styleClass)
          Creates a label that will display the supplied text using the specified style class.
 
Method Summary
protected  Dimension computePreferredSize(int whint, int hhint)
          Computes and returns a preferred size for this component.
protected  String getDefaultStyleClass()
          Returns the default stylesheet class to be used for all instances of this component.
 BLabel.Fit getFit()
          Returns the current fit mode for this label.
 BIcon getIcon()
          Returns the icon being displayed by this label.
 int getIconTextGap()
          Returns the gap between the icon and the text.
 String getText()
          Returns the text currently being displayed by this component.
protected  void layout()
          Instructs this component to lay itself out.
protected  void renderComponent(Renderer renderer)
          Renders any custom bits for this component.
 void setFit(BLabel.Fit mode)
          Configures whether this label will wrap, truncate or scale if it cannot fit text into its allotted width.
 void setIcon(BIcon icon)
          Configures the label to display the specified icon.
 void setIconTextGap(int gap)
          Configures the gap between the icon and the text.
 void setOrientation(int orient)
          Sets the orientation of this label with respect to its icon.
 void setText(String text)
          Updates the text displayed by this component.
protected  void wasAdded()
          This method is called when we are added to a hierarchy that is connected to a top-level window (at which point we can rely on having a look and feel and can set ourselves up).
protected  void wasRemoved()
          This method is called when we are removed from a hierarchy that is connected to a top-level window.
 
Methods inherited from class com.jmex.bui.BTextComponent
checkNonDefault, checkNonDefaultInt, checkNonDefaultVal, configureStyle, getEffectColor, getEffectSize, getHorizontalAlignment, getLabelConfig, getLineSpacing, getTextEffect, getTextFactory, getTextFactory, getVerticalAlignment
 
Methods inherited from class com.jmex.bui.BComponent
acceptsFocus, addListener, applyDefaultStates, boundsToString, changeCursor, createTooltipComponent, dispatchEvent, emitEvent, getAbsoluteX, getAbsoluteY, getAlpha, getBackground, getBorder, getBounds, getColor, getCursor, getFocusTarget, getHeight, getHitComponent, getInsets, getNextFocus, getParent, getPreferredSize, getPreviousFocus, getProperty, getState, getStateCount, getStatePseudoClass, getStyleClass, getTooltipText, getWidth, getWindow, getX, getY, hasFocus, intersectScissorBox, invalidate, isAdded, isEnabled, isShowing, isTooltipRelativeToMouse, isValid, isVisible, removeAllListeners, removeListener, render, renderBackground, renderBorder, requestFocus, restoreScissorState, setAlpha, setBackground, setBounds, setCursor, setEnabled, setLocation, setParent, setPreferredSize, setPreferredSize, setProperty, setSize, setStyleClass, setTooltipRelativeToMouse, setTooltipText, setVisible, stateDidChange, updateCursor, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_label

protected Label _label
Constructor Detail

BLabel

public BLabel(String text)
Creates a label that will display the supplied text.


BLabel

public BLabel(String text,
              String styleClass)
Creates a label that will display the supplied text using the specified style class.


BLabel

public BLabel(BIcon icon)
Creates a label that will display the supplied icon.


BLabel

public BLabel(BIcon icon,
              String styleClass)
Creates a label that will display the supplied icon using the specified style class.


BLabel

public BLabel(BIcon icon,
              String text,
              String styleClass)
Creates a label that will display the supplied text and icon using the specified style class. All arguments can be null.

Method Detail

setIcon

public void setIcon(BIcon icon)
Configures the label to display the specified icon.


getIcon

public BIcon getIcon()
Returns the icon being displayed by this label.


setIconTextGap

public void setIconTextGap(int gap)
Configures the gap between the icon and the text.


getIconTextGap

public int getIconTextGap()
Returns the gap between the icon and the text.


setOrientation

public void setOrientation(int orient)
Sets the orientation of this label with respect to its icon. If the horizontal (the default) the text is displayed to the right of the icon, if vertical the text is displayed below it.


setFit

public void setFit(BLabel.Fit mode)
Configures whether this label will wrap, truncate or scale if it cannot fit text into its allotted width. The default is to wrap.


getFit

public BLabel.Fit getFit()
Returns the current fit mode for this label.


setText

public void setText(String text)
Description copied from class: BTextComponent
Updates the text displayed by this component.

Specified by:
setText in class BTextComponent

getText

public String getText()
Description copied from class: BTextComponent
Returns the text currently being displayed by this component.

Specified by:
getText in class BTextComponent

getDefaultStyleClass

protected String getDefaultStyleClass()
Description copied from class: BComponent
Returns the default stylesheet class to be used for all instances of this component. Derived classes will likely want to override this method and set up a default class for their type of component.

Overrides:
getDefaultStyleClass in class BComponent

wasAdded

protected void wasAdded()
Description copied from class: BComponent
This method is called when we are added to a hierarchy that is connected to a top-level window (at which point we can rely on having a look and feel and can set ourselves up).

Overrides:
wasAdded in class BComponent

wasRemoved

protected void wasRemoved()
Description copied from class: BComponent
This method is called when we are removed from a hierarchy that is connected to a top-level window. If we wish to clean up after things done in BComponent.wasAdded(), this is a fine place to do so.

Overrides:
wasRemoved in class BComponent

layout

protected void layout()
Description copied from class: BComponent
Instructs this component to lay itself out. This is called as a result of the component changing size.

Overrides:
layout in class BComponent

renderComponent

protected void renderComponent(Renderer renderer)
Description copied from class: BComponent
Renders any custom bits for this component. This is called with the graphics context translated to (0, 0) relative to this component.

Overrides:
renderComponent in class BComponent

computePreferredSize

protected Dimension computePreferredSize(int whint,
                                         int hhint)
Description copied from class: BComponent
Computes and returns a preferred size for this component. This method is called if no overriding preferred size has been supplied.

Overrides:
computePreferredSize in class BComponent
Returns:
the computed preferred size of this component in a newly created Dimension instance which will be adopted (and modified) by the caller.


Copyright © 2008 Michael Bayne. All Rights Reserved.