buoy.widget

Class 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(Icon image)
Create a new BLabel which displays an image.
BLabel(Icon image, BLabel.Position align)
Create a new BLabel which displays an image.
BLabel(String text)
Create a new BLabel which displays text.
BLabel(String text, Icon image, BLabel.Position align, BLabel.Position textPos)
Create a new BLabel which displays both text and an image.
BLabel(String text, BLabel.Position align)
Create a new BLabel which displays text.

Method Summary

BLabel.Position
getAlignment()
Get the alignment of the label's contents.
JLabel
getComponent()
Icon
getIcon()
Get the image which appears on this label.
Dimension
getMaximumSize()
Get the largest size at which this Widget can reasonably be drawn.
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(Icon image)
Set the image which appears on this label.
void
setText(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, getComponent, getCursor, getFont, getMaximumSize, 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, addEventLink, dispatchEvent, removeEventLink

Field Details

CENTER

public static final BLabel.Position CENTER

EAST

public static final BLabel.Position EAST

NORTH

public static final BLabel.Position NORTH

NORTHEAST

public static final BLabel.Position NORTHEAST

NORTHWEST

public static final BLabel.Position NORTHWEST

SOUTH

public static final BLabel.Position SOUTH

SOUTHEAST

public static final BLabel.Position SOUTHEAST

SOUTHWEST

public static final BLabel.Position SOUTHWEST

WEST

public static final BLabel.Position WEST

Constructor Details

BLabel

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

BLabel

public BLabel(Icon image)
Create a new BLabel which displays an image.
Parameters:
image - the image to display on the BLabel

BLabel

public BLabel(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(String text)
Create a new BLabel which displays text.
Parameters:
text - the text to display on the BLabel

BLabel

public BLabel(String text,
              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.)

BLabel

public BLabel(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.)

Method Details

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.

getComponent

public JLabel getComponent()
Overrides:
getComponent in interface Widget

getIcon

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

getMaximumSize

public 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 interface Widget

getText

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

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.

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.

setIcon

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

setText

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

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.