buoy.widget
Class BButton

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

public class BButton
extends Widget

A BButton is a pushbutton Widget. Its appearance can be customized by setting the text and/or image which appears on it.

In addition to the event types generated by all Widgets, BButtons generate the following event types:

Author:
Peter Eastman

Nested Class Summary
static class BButton.Position
          This inner class represents a value for the alignment or text position.
 
Field Summary
static BButton.Position CENTER
           
static BButton.Position EAST
           
static BButton.Position NORTH
           
static BButton.Position NORTHEAST
           
static BButton.Position NORTHWEST
           
static BButton.Position SOUTH
           
static BButton.Position SOUTHEAST
           
static BButton.Position SOUTHWEST
           
static BButton.Position WEST
           
 
Constructor Summary
BButton()
          Create a new BButton with no set text or image.
BButton(javax.swing.Icon icon)
          Create a new BButton.
BButton(java.lang.String text)
          Create a new BButton.
BButton(java.lang.String text, javax.swing.Icon icon)
          Create a new BButton.
 
Method Summary
 java.lang.String getActionCommand()
          Get the "action command" which will be sent in a CommandEvent when this button is pressed.
 javax.swing.JButton getComponent()
          Get the java.awt.Component corresponding to this Widget.
 javax.swing.Icon getIcon()
          Get the image being displayed on the button.
 java.awt.Dimension getMaximumSize()
          Get the largest size at which this Widget can reasonably be drawn.
 java.lang.String getText()
          Get the text being displayed on the button.
 BButton.Position getTextPosition()
          Get the position of the text relative to the image.
 void setActionCommand(java.lang.String command)
          Set the "action command" which will be sent in a CommandEvent when this button is pressed.
 void setIcon(javax.swing.Icon icon)
          Set the image being displayed on the button.
 void setText(java.lang.String text)
          Set the text being displayed on the button.
 void setTextPosition(BButton.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 BButton.Position CENTER

NORTH

public static final BButton.Position NORTH

SOUTH

public static final BButton.Position SOUTH

WEST

public static final BButton.Position WEST

EAST

public static final BButton.Position EAST

NORTHEAST

public static final BButton.Position NORTHEAST

SOUTHEAST

public static final BButton.Position SOUTHEAST

NORTHWEST

public static final BButton.Position NORTHWEST

SOUTHWEST

public static final BButton.Position SOUTHWEST
Constructor Detail

BButton

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


BButton

public BButton(java.lang.String text)
Create a new BButton.

Parameters:
text - the text to display on the button

BButton

public BButton(javax.swing.Icon icon)
Create a new BButton.

Parameters:
icon - the image to display on the button

BButton

public BButton(java.lang.String text,
               javax.swing.Icon icon)
Create a new BButton.

Parameters:
text - the text to display on the button
icon - the image to display on the button
Method Detail

getComponent

public javax.swing.JButton 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 being displayed on the button. This may be null.


setText

public void setText(java.lang.String text)
Set the text being displayed on the button. This may be null.


getIcon

public javax.swing.Icon getIcon()
Get the image being displayed on the button. This may be null.


setIcon

public void setIcon(javax.swing.Icon icon)
Set the image being displayed on the button. This may be null.


getActionCommand

public java.lang.String getActionCommand()
Get the "action command" which will be sent in a CommandEvent when this button is pressed.


setActionCommand

public void setActionCommand(java.lang.String command)
Set the "action command" which will be sent in a CommandEvent when this button is pressed.


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

getTextPosition

public BButton.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(BButton.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 BButton does not display both text and an image, this method will have no effect.



Written by Peter Eastman.