Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

Class gui.TabPanel

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--gui.TabPanel

public class TabPanel
extends java.awt.Panel
TabPanel is a container for a set of tabbed cards, lying atop each other, but with the labelled tabs exposed at the top. That is, the classic Tab Folder. Each card is an awt.component of whatever design you wish. The topmost card can be selected programmatically (Using first(), last(), next(), previous(), or show(name)), or by clicking on the tab with the mouse.

Components should be added using add(name,component)); the name is used to label the tab. If you set the layout manager, it should be a subclass of CardLayout. You probably want to setBackground() to a color contrasting that of the parent and the components.

Whenever a card is selected (whether by software or mouse), an event with id = Event.WINDOW_EXPOSE is sent to the selected component. Handling this event may be useful for deferred initialization.

See Also:
Serialized Form

Field Summary
int margin
          The width of the margins around the cards.
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
TabPanel()
          Creates an empty TabPanel.
 
Method Summary
java.awt.Component add(java.lang.String name, java.awt.Component component)
          Add a card, component, to the TabPanel with a given name.
java.lang.String documentCard(java.lang.String name)
          Return a mouse documentation string for selecting this card. (ie. the applet status line (if there is an applet), for when the mouse is over the tab).
void first()
          Select the first card in the Panel.
boolean handleEvent(java.awt.Event e)
          Handle mouse clicks and documentation line for Tab selection.
java.awt.Insets insets()
          Allocates extra margins to give the cards some `body'.
void last()
          Select the last card in the Panel.
void layout()
          Computes tab geometry while laying out the panels components.
void next()
          Select the next card in the Panel.
void paint(java.awt.Graphics g)
          Paint the tabs in a row atop the cards.
void previous()
          Select the previous card in the Panel.
void removeAll()
          remove all cards from the TabPanel.
void remove(java.awt.Component component)
          remove the card, component, from the TabPanel.
void remove(java.lang.String name)
          remove the card having the given name from the TabPanel.
void setTabFont(java.awt.Font font)
          Specify the Font to be used for labeling the Tabs.
void show(java.lang.String name)
          Select the named card in the Panel.
void show(java.awt.Component component)
          Select the card component in the Panel.
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addNotify, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponentAt, getComponentAt, getComponent, getComponentCount, getComponents, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, paint, paramString, preferredSize, printComponents, print, processContainerEvent, processEvent, removeAll, remove, remove, removeContainerListener, removeNotify, setLayout, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getParent, getPeer, getPreferredSize, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paint, paramString, postEvent, preferredSize, prepareImage, prepareImage, printAll, print, processComponentEvent, processEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, update, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait
 

Field Detail

margin

public int margin
The width of the margins around the cards.
Constructor Detail

TabPanel

public TabPanel()
Creates an empty TabPanel.
Method Detail

add

public java.awt.Component add(java.lang.String name,
                     java.awt.Component component)
Add a card, component, to the TabPanel with a given name.
Overrides:
add in class java.awt.Container

remove

public void remove(java.awt.Component component)
remove the card, component, from the TabPanel.
Overrides:
remove in class java.awt.Container

remove

public void remove(java.lang.String name)
remove the card having the given name from the TabPanel.

removeAll

public void removeAll()
remove all cards from the TabPanel.
Overrides:
removeAll in class java.awt.Container

first

public void first()
Select the first card in the Panel.

last

public void last()
Select the last card in the Panel.

next

public void next()
Select the next card in the Panel.

previous

public void previous()
Select the previous card in the Panel.

show

public void show(java.lang.String name)
Select the named card in the Panel.

show

public void show(java.awt.Component component)
Select the card component in the Panel.

documentCard

public java.lang.String documentCard(java.lang.String name)
Return a mouse documentation string for selecting this card. (ie. the applet status line (if there is an applet), for when the mouse is over the tab). This may be overridden by a subclass, if desired. The default is to use the "Select tab card " + name.

handleEvent

public boolean handleEvent(java.awt.Event e)
Handle mouse clicks and documentation line for Tab selection.
Overrides:
handleEvent in class java.awt.Component

insets

public java.awt.Insets insets()
Allocates extra margins to give the cards some `body'.
Overrides:
insets in class java.awt.Container

setTabFont

public void setTabFont(java.awt.Font font)
Specify the Font to be used for labeling the Tabs. This avoids getting in the way of cards inheriting default fonts from the TabPanel's container.

layout

public void layout()
Computes tab geometry while laying out the panels components.
Overrides:
layout in class java.awt.Container

paint

public void paint(java.awt.Graphics g)
Paint the tabs in a row atop the cards.
Overrides:
paint in class java.awt.Container

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD