buoy.widget
Class BLabel

java.lang.Object
  extended by buoy.event.EventSource
      extended by buoy.widget.Widget
          extended by buoy.widget.BLabel

public class BLabel
extends Widget

A BLabel is a Widget that displays a text string, an image, or both. The text may be specified as HTML, allowing it to contain complex formatting, multiple fonts, etc.

Author:
Peter Eastman

Nested Class Summary
static class BLabel.Position
          This inner class represents a value for the alignment or text position.
 
Field Summary
static BLabel.Position CENTER
           
static BLabel.Position EAST
           
static BLabel.Position NORTH
           
static BLabel.Position NORTHEAST
           
static BLabel.Position NORTHWEST
           
static BLabel.Position SOUTH
           
static BLabel.Position SOUTHEAST
           
static BLabel.Position SOUTHWEST
           
static BLabel.Position WEST
           
 
Constructor Summary
BLabel()
          Create a new BLabel with no text or image.
BLabel(javax.swing.Icon image)
          Create a new BLabel which displays an image.
BLabel(javax.swing.Icon image, BLabel.Position align)
          Create a new BLabel which displays an image.
BLabel(java.lang.String text)
          Create a new BLabel which displays text.
BLabel(java.lang.String text, BLabel.Position align)
          Create a new BLabel which displays text.
BLabel(java.lang.String text, javax.swing.Icon image, BLabel.Position align, BLabel.Position textPos)
          Create a new BLabel which displays both text and an image.
 
Method Summary
 BLabel.Position getAlignment()
          Get the alignment of the label's contents.
 javax.swing.JLabel getComponent()
          Get the java.awt.Component corresponding to this Widget.
 javax.swing.Icon getIcon()
          Get the image which appears on this label.
 java.awt.Dimension getMaximumSize()
          Get the largest size at which this Widget can reasonably be drawn.
 java.lang.String getText()
          Get the text which appears on this label.
 BLabel.Position getTextPosition()
          Get the position of the text relative to the image.
 void setAlignment(BLabel.Position alignment)
          Set the alignment of the label's contents.
 void setIcon(javax.swing.Icon image)
          Set the image which appears on this label.
 void setText(java.lang.String text)
          Set the text which appears on this label.
 void setTextPosition(BLabel.Position position)
          Set the position of the text relative to the image.
 
Methods inherited from class buoy.widget.Widget
addEventLink, dispatchEvent, getBackground, getBounds, getCursor, getFont, getMinimumSize, getName, getParent, getPreferredSize, hasFocus, isEnabled, isFocusable, isVisible, repaint, requestFocus, setBackground, setCursor, setEnabled, setFocusable, setFont, setName, setVisible
 
Methods inherited from class buoy.event.EventSource
addEventLink, addEventLink, removeEventLink
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CENTER

public static final BLabel.Position CENTER

NORTH

public static final BLabel.Position NORTH

SOUTH

public static final BLabel.Position SOUTH

WEST

public static final BLabel.Position WEST

EAST

public static final BLabel.Position EAST

NORTHEAST

public static final BLabel.Position NORTHEAST

SOUTHEAST

public static final BLabel.Position SOUTHEAST

NORTHWEST

public static final BLabel.Position NORTHWEST

SOUTHWEST

public static final BLabel.Position SOUTHWEST
Constructor Detail

BLabel

public BLabel()
Create a new BLabel with no text or image.


BLabel

public BLabel(java.lang.String text)
Create a new BLabel which displays text.

Parameters:
text - the text to display on the BLabel

BLabel

public BLabel(java.lang.String text,
              BLabel.Position align)
Create a new BLabel which displays text.

Parameters:
text - the text to display on the BLabel
align - the alignment of the label contents (CENTER, NORTH, NORTHEAST, etc.)

BLabel

public BLabel(javax.swing.Icon image)
Create a new BLabel which displays an image.

Parameters:
image - the image to display on the BLabel

BLabel

public BLabel(javax.swing.Icon image,
              BLabel.Position align)
Create a new BLabel which displays an image.

Parameters:
image - the image to display on the BLabel
align - the alignment of the label contents (CENTER, NORTH, NORTHEAST, etc.)

BLabel

public BLabel(java.lang.String text,
              javax.swing.Icon image,
              BLabel.Position align,
              BLabel.Position textPos)
Create a new BLabel which displays both text and an image.

Parameters:
text - the text to display on the BLabel
image - the image to display on the BLabel
align - the alignment of the label contents (CENTER, NORTH, NORTHEAST, etc.)
textPos - the position of the text relative to the image (CENTER, NORTH, NORTHEAST, etc.)
Method Detail

getComponent

public javax.swing.JLabel getComponent()
Description copied from class: Widget
Get the java.awt.Component corresponding to this Widget.

Overrides:
getComponent in class Widget

getText

public java.lang.String getText()
Get the text which appears on this label.


setText

public void setText(java.lang.String text)
Set the text which appears on this label.


getIcon

public javax.swing.Icon getIcon()
Get the image which appears on this label.


setIcon

public void setIcon(javax.swing.Icon image)
Set the image which appears on this label.


getMaximumSize

public java.awt.Dimension getMaximumSize()
Get the largest size at which this Widget can reasonably be drawn. When a WidgetContainer lays out its contents, it will attempt never to make this Widget larger than its maximum size.

Overrides:
getMaximumSize in class Widget

getAlignment

public BLabel.Position getAlignment()
Get the alignment of the label's contents. This will be one of the alignment constants defined by this class: CENTER, NORTH, NORTHEAST, EAST, etc.


setAlignment

public void setAlignment(BLabel.Position alignment)
Set the alignment of the label's contents. This should be one of the alignment constants defined by this class: CENTER, NORTH, NORTHEAST, EAST, etc.


getTextPosition

public BLabel.Position getTextPosition()
Get the position of the text relative to the image. This will be one of the alignment constants defined by this class: CENTER, NORTH, NORTHEAST, EAST, etc.


setTextPosition

public void setTextPosition(BLabel.Position position)
Set the position of the text relative to the image. This should be one of the alignment constants defined by this class: CENTER, NORTH, NORTHEAST, EAST, etc. If this BLabel does not display both text and an image, this method will have no effect.



Written by Peter Eastman.