jewl
Class TabbedPanel

java.lang.Object
  extended byjewl.Window
      extended byjewl.Container
          extended byjewl.TabbedPanel

public class TabbedPanel
extends Container

A set of overlapped pages, each of which is a separate container for other windows. Each page has a tab at the top of the panel which displays the page's title. Clicking a tab with the mouse brings the corresponding page to the front. You can also use the left and right arrow keys on the keyboard to move between pages.

Each page acts as a separate container. When a window is added to a TabbedPanel, it is actually added to the currently-selected page.

A TabbedPanel will call any registered event listeners when a new page is selected.


Constructor Summary
TabbedPanel(Container parent, int left, int top, int width, int height, java.lang.String title)
          Construct a tabbed panel with a single page.
 
Method Summary
 int addPage(java.lang.String title)
          Add a new page to the panel.
 int getBorderHeight()
          Get the total height of the top and bottom borders of this panel.
 int getBorderWidth()
          Get the total width of the left and right borders of this panel.
 Font getFont()
          Get the current font used for the tabs in this panel.
 int getPage()
          Get the index of currently-selected page.
 java.lang.String getTitle()
          Get the title for the currently-selected page.
 java.lang.String getTitle(int page)
          Get the title for a specified page.
 void selectPage(int page)
          Select a specific page.
 void setFont(java.awt.Font font)
          Set the font to be used for the tabs on this panel.
 void setTitle(int page, java.lang.String title)
          Set the title for a specified page.
 void setTitle(java.lang.String title)
          Set the title for the currently-selected page.
 
Methods inherited from class jewl.Container
getInteriorHeight, getInteriorWidth
 
Methods inherited from class jewl.Window
addEventListener, commandAvailable, getCommand, getHeight, getID, getLeft, getScreenHeight, getScreenWidth, getSource, getTop, getWidth, hide, init, isVisible, nextCommand, parent, root, setID, setLocation, setSize, show, show
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TabbedPanel

public TabbedPanel(Container parent,
                   int left,
                   int top,
                   int width,
                   int height,
                   java.lang.String title)
Construct a tabbed panel with a single page.

Parameters:
parent - the panel's parent window.
left - the position of the left edge of the panel relative to its parent. If this is negative, it is taken to be relative to the right edge of the parent window. If the parent window is resized, the panel will be moved to maintain the same relative position.
top - the position of the top edge of the panel relative to its parent. If this is negative, it is taken to be relative to the bottom edge of the parent window. If the parent window is resized, the panel will be moved to maintain the same relative position.
width - the width of the panel. If this is zero or negative, it is taken to be relative to the width of the parent window. If the parent window is resized, the panel will be resized to maintain the same relative width.
height - the height of the panel. If this is zero or negative, it is taken to be relative to the height of the parent window. If the parent window is resized, the panel will be resized to maintain the same relative height.
title - the title for the panel's initial page.
Method Detail

getBorderWidth

public int getBorderWidth()
Get the total width of the left and right borders of this panel.

Overrides:
getBorderWidth in class Container
Returns:
The total width of the left and right borders of this panel in pixels.

getBorderHeight

public int getBorderHeight()
Get the total height of the top and bottom borders of this panel.

Overrides:
getBorderHeight in class Container
Returns:
The total width of the top and bottom borders of this panel in pixels.

addPage

public int addPage(java.lang.String title)
Add a new page to the panel. This also selects the new page as the current page and returns the number of the new page.

Parameters:
title - the title of the new page.
Returns:
The index of the new page.

getPage

public int getPage()
Get the index of currently-selected page.

Returns:
The index of the currently-selected page. The pages are numbered from 0 upwards.

selectPage

public void selectPage(int page)
Select a specific page. This will bring the page and any windows it contains to the front, hiding the contents of all the other pages.

Parameters:
page - the number of the required page.
Throws:
java.lang.IllegalArgumentException - if there is no such tab.

getTitle

public java.lang.String getTitle(int page)
Get the title for a specified page.

Parameters:
page - the number of the page.
Returns:
The title of the specified page.
Throws:
java.lang.IllegalArgumentException - if the page number is invalid.

getTitle

public java.lang.String getTitle()
Get the title for the currently-selected page.

Specified by:
getTitle in class Container
Returns:
The title of the current page.

setTitle

public void setTitle(int page,
                     java.lang.String title)
Set the title for a specified page.

Parameters:
page - the number of the page.
title - the new title for the specified page.
Throws:
java.lang.IllegalArgumentException - if the page number is invalid.

setTitle

public void setTitle(java.lang.String title)
Set the title for the currently-selected page.

Specified by:
setTitle in class Container
Parameters:
title - the new title for the current page.

setFont

public void setFont(java.awt.Font font)
Set the font to be used for the tabs on this panel.

Overrides:
setFont in class Window
Parameters:
font - the desired font to be applied. If this is null, the parent window's font will be used. Although this is specified as a java.awt.Font, you can use jewl.Font instead.
See Also:
Font

getFont

public Font getFont()
Get the current font used for the tabs in this panel.

Overrides:
getFont in class Window
Returns:
The current font used for the tabs in this panel.