buoy.widget
Class BTabbedPane

java.lang.Object
  extended by buoy.event.EventSource
      extended by buoy.widget.Widget
          extended by buoy.widget.WidgetContainer
              extended by buoy.widget.BTabbedPane

public class BTabbedPane
extends WidgetContainer

BTabbedPane is a WidgetContainer which arranges its child Widgets in a row.

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

Author:
Peter Eastman

Nested Class Summary
static class BTabbedPane.TabPosition
          This inner class represents a position for the tabs.
 
Field Summary
static BTabbedPane.TabPosition BOTTOM
           
static BTabbedPane.TabPosition LEFT
           
static BTabbedPane.TabPosition RIGHT
           
static BTabbedPane.TabPosition TOP
           
 
Constructor Summary
BTabbedPane()
          Create a new BTabbedPane with the tabs along the top.
BTabbedPane(BTabbedPane.TabPosition pos)
          Create a new TabbedContainer.
 
Method Summary
 void add(Widget widget, java.lang.String tabName)
          Add a Widget to this container.
 void add(Widget widget, java.lang.String tabName, javax.swing.Icon image)
          Add a Widget to this container.
 void add(Widget widget, java.lang.String tabName, javax.swing.Icon image, int index)
          Add a Widget to this container.
 Widget getChild(int i)
          Get the i'th child of this container.
 int getChildCount()
          Get the number of children in this container.
 int getChildIndex(Widget widget)
          Get the index of a particular Widget.
 java.util.Collection<Widget> getChildren()
          Get a Collection containing all child Widgets of this container.
 javax.swing.JTabbedPane getComponent()
          Get the java.awt.Component corresponding to this Widget.
 int getSelectedTab()
          Get the index of the tab which is currently selected.
 javax.swing.Icon getTabImage(int index)
          Get the image displayed on a particular tab.
 java.lang.String getTabName(int index)
          Get the name displayed on a particular tab.
 BTabbedPane.TabPosition getTabPosition()
          Get the position of the tabs (TOP, LEFT, BOTTOM, or RIGHT).
 void layoutChildren()
          Layout the child Widgets.
 void remove(int index)
          Remove a child Widget from this container.
 void remove(Widget widget)
          Remove a child Widget from this container.
 void removeAll()
          Remove all child Widgets from this container.
 void setSelectedTab(int index)
          Set which tab is selected.
 void setTabImage(int index, javax.swing.Icon image)
          Set the image displayed on a particular tab.
 void setTabName(int index, java.lang.String name)
          Set the name displayed on a particular tab.
 void setTabPosition(BTabbedPane.TabPosition pos)
          Set the position of the tabs (TOP, LEFT, BOTTOM, or RIGHT).
 
Methods inherited from class buoy.widget.WidgetContainer
isOpaque, setOpaque
 
Methods inherited from class buoy.widget.Widget
addEventLink, dispatchEvent, getBackground, getBounds, 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, removeEventLink
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TOP

public static final BTabbedPane.TabPosition TOP

LEFT

public static final BTabbedPane.TabPosition LEFT

BOTTOM

public static final BTabbedPane.TabPosition BOTTOM

RIGHT

public static final BTabbedPane.TabPosition RIGHT
Constructor Detail

BTabbedPane

public BTabbedPane()
Create a new BTabbedPane with the tabs along the top.


BTabbedPane

public BTabbedPane(BTabbedPane.TabPosition pos)
Create a new TabbedContainer.

Parameters:
pos - the position for the tabs (TOP, LEFT, BOTTOM, or RIGHT)
Method Detail

getComponent

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

Overrides:
getComponent in class Widget

getChildCount

public int getChildCount()
Get the number of children in this container.

Specified by:
getChildCount in class WidgetContainer

getChild

public Widget getChild(int i)
Get the i'th child of this container.


getChildren

public java.util.Collection<Widget> getChildren()
Get a Collection containing all child Widgets of this container.

Specified by:
getChildren in class WidgetContainer

layoutChildren

public void layoutChildren()
Layout the child Widgets. This may be invoked whenever something has changed (the size of this WidgetContainer, the preferred size of one of its children, etc.) that causes the layout to no longer be correct. If a child is itself a WidgetContainer, its layoutChildren() method will be called in turn.

Specified by:
layoutChildren in class WidgetContainer

add

public void add(Widget widget,
                java.lang.String tabName)
Add a Widget to this container.

Parameters:
widget - the Widget to add
tabName - the name to display on the tab

add

public void add(Widget widget,
                java.lang.String tabName,
                javax.swing.Icon image)
Add a Widget to this container.

Parameters:
widget - the Widget to add
tabName - the name to display on the tab
image - the image to display on the tab

add

public void add(Widget widget,
                java.lang.String tabName,
                javax.swing.Icon image,
                int index)
Add a Widget to this container.

Parameters:
widget - the Widget to add
tabName - the name to display on the tab
image - the image to display on the tab
index - the position at which to add this tab

remove

public void remove(Widget widget)
Remove a child Widget from this container.

Specified by:
remove in class WidgetContainer
Parameters:
widget - the Widget to remove

remove

public void remove(int index)
Remove a child Widget from this container.

Parameters:
index - the index of the Widget to remove

removeAll

public void removeAll()
Remove all child Widgets from this container.

Specified by:
removeAll in class WidgetContainer

getChildIndex

public int getChildIndex(Widget widget)
Get the index of a particular Widget.

Parameters:
widget - the Widget to locate
Returns:
the position of the Widget within this container

getTabPosition

public BTabbedPane.TabPosition getTabPosition()
Get the position of the tabs (TOP, LEFT, BOTTOM, or RIGHT).


setTabPosition

public void setTabPosition(BTabbedPane.TabPosition pos)
Set the position of the tabs (TOP, LEFT, BOTTOM, or RIGHT).


getTabName

public java.lang.String getTabName(int index)
Get the name displayed on a particular tab.

Parameters:
index - the index of the tab

setTabName

public void setTabName(int index,
                       java.lang.String name)
Set the name displayed on a particular tab.

Parameters:
index - the index of the tab
name - the name to display

getTabImage

public javax.swing.Icon getTabImage(int index)
Get the image displayed on a particular tab.

Parameters:
index - the index of the tab

setTabImage

public void setTabImage(int index,
                        javax.swing.Icon image)
Set the image displayed on a particular tab.

Parameters:
index - the index of the tab
image - the image to display

getSelectedTab

public int getSelectedTab()
Get the index of the tab which is currently selected.


setSelectedTab

public void setSelectedTab(int index)
Set which tab is selected.

Parameters:
index - the index of the tab


Written by Peter Eastman.