TabStrip Class

TabStrip Class

This Package | All Packages

Component
  |
  +--Control
    |
    +--TabStrip
public class TabStrip
extends Control

A control for creating tabbed dialogs or tabbed toolbar/taskbar type windows. This control provides one or more rows of tabs that the user can select, one at a time. After each selection, a notification is provided that allows for the changing of the UI. Two basic UI modes that are supported are the traditional tabs seen in property page scenarios and a button-style tab, as in the taskbar found in Windows 95 and Windows NT version 4.0.

Constructors
Name Description
TabStrip() Creates a TabStrip control.

Methods
Name Description
addOnDrawItem(DrawItemEventHandler value) Adds an event handler for the OnDrawItem event notification.
addOnSelectionChange(EventHandler value) Adds an event handler for the OnSelectionChange event notification.
addTab(Object item) Adds a tab to the TabStrip.
createHandle() Topic under construction.
getDisplayRect() Returns the rectangle that represents the area of the tab control not taken up by the tabs, borders, or anything else owned by the tab.
getDrawStyle() Indicates whether the individual tabs are painted by Windows or by the end user.
getItemSize() Topic under construction.
getMultiline() Indicates whether there can be more than one row of tabs.
getPadding() Retrieves the amount of padding around the items in the individual tabs.
getRowCount() Retrieves the number of rows currently being displayed in the TabStrip.
getSelectedIndex() Retrieves the index of the currently selected tab in the strip, if there is one.
getSizeMode() Retrieves the size mode.
getTabCount() Retrieves the number of tabs in the strip.
getTabRect(int index) Retrieves the bounding rectangle for the given tab in the TabStrip.
getTabs() Retrieves an Object array containing all the items in the TabStrip.
getTabStyle() Indicates whether the tabs in the TabStrip look like regular tabs as seen in property sheet applications, or if they look like butttons, as seen in the Windows 95 taskbar.
getTabText(int index) Retrieves the text for the given tab.
insertTab(int index, Object item) Adds a tab to the TabStrip, but in a location you specify, as opposed to the end of the list.
recreateHandle() Ovveride this to guarantee that the tabs are re-created when appropriate.
removeAll() Removes all tabs from the TabStrip.
removeOnDrawItem(DrawItemEventHandler value) Removes the given handler for the OnDrawItem event.
removeOnSelectionChange(EventHandler value) Removes the given handler for the OnSelectionChange event.
removeTab(int index) Removes the tab at the given index of the TabStrip.
setDisplayRectSize(int width, int height) Sets the size of the tabstrip based on a desired size for the display rectangle.
setDisplayRectSize(Point p) Sets the size of the tabstrip based on a desired size for the display rectangle.
setDrawStyle(int value) Indicates whether the individual tabs are painted by Windows or by the end user.
setItemSize(Point size) Topic under construction.
setMultiline(boolean value) Indicates whether there can be more than one row of tabs.
setPadding(Point value) Sets the amount of padding around the items in the individual tabs.
setSelectedIndex(int index) Sets the tab at the supplied index as being the selected tab in the strip.
setSizeMode(int value) Sets the size mode.
setTabs(Object[] value) Sets all the tabs in the TabStrip at once by passing in an array with all their values.
setTabStyle(int value) Indicates whether the tabs in the TabStrip look like regular tabs as seen in property sheet applications, or if they look like butttons, as seen in the Windows 95 taskbar.
setTabText(int index, String value) Sets the text for the given tab.

Constructors

TabStrip.TabStrip

Syntax
public TabStrip();
Description

Creates a TabStrip control.

Methods

TabStrip.addOnDrawItem

Syntax
public final void addOnDrawItem( DrawItemEventHandler value );
Parameters
value
New event handler to install for this event.
Description

Adds an event handler for the OnDrawItem event notification. This event is called for list boxes whose listStyle property is set to DrawStyle.OwnerDrawFixed and contains a Graphics object in which the item should be painted. Duplicates adds are not filtered out.

TabStrip.addOnSelectionChange

Syntax
public final void addOnSelectionChange( EventHandler value );
Parameters
value
New event handler to install for this event.
Description

Adds an event handler for the OnSelectionChange event notification. This event is sent whenever a new tab is selected. Duplicates are not filtered out.

TabStrip.addTab

Syntax
public final int addTab( Object item );
Parameters
item
The item that identifies the text to insert into the TabStrip.
Return Value

Returns the index of where the item was inserted.

Description

Adds a tab to the TabStrip. The code that adds the item calls toString() on it and inserts that value into the tab caption.

TabStrip.createHandle

Syntax
protected void createHandle();
Description

Topic under construction.

Overrides

createHandle() in Control.

TabStrip.getDisplayRect

Syntax
public final Rectangle getDisplayRect();
Return Value

Returns the rectangle with the display area of the TabStrip.

Description

Returns the rectangle that represents the area of the tab control not taken up by the tabs, borders, or anything else owned by the tab. This is typically the rectangle you want to use to place the individual children of the tab control.

TabStrip.getDrawStyle

Syntax
public final int getDrawStyle();
Return Value

Returns one of the following integer values:

Description

Indicates whether the individual tabs are painted by Windows or by the end user. If the latter, an OnDrawItem event is fired whenever an item needs to be painted. All items must still be the same height.

TabStrip.getItemSize

Syntax
public final Point getItemSize();
Description

Topic under construction.

TabStrip.getMultiline

Syntax
public final boolean getMultiline();
Return Value

Returns a boolean value indicating whether multiple rows are allowed.

Description

Indicates whether there can be more than one row of tabs. By default (when this property is false), if there are more tabs than available display space, arrows are shown to let the user navigate between the extra tabs, but only one row is shown. If this property is set to true, then Windows spills extra tabs over onto second rows.

TabStrip.getPadding

Syntax
public final Point getPadding();
Return Value

Returns a point whose width contains the horizontal padding and whose height contains the vertical padding.

Description

Retrieves the amount of padding around the items in the individual tabs.

TabStrip.getRowCount

Syntax
public final int getRowCount();
Return Value

Returns the count of rows currently being used.

Description

Retrieves the number of rows currently being displayed in the TabStrip. This is most commonly used when the Multline property is true and you want to know how many rows are being used to display the tabs.

TabStrip.getSelectedIndex

Syntax
public final int getSelectedIndex();
Return Value

Returns the currently selected tab.

Description

Retrieves the index of the currently selected tab in the strip, if there is one. If the value is -1, there is currently no selection. If the value is 0 or greater, the value is the index of the currently selected tab.

TabStrip.getSizeMode

Syntax
public final int getSizeMode();
Return Value

Returns one of the following integer values:

Description

Retrieves the size mode. By default, tabs are big enough to display their text, and any space on the right of the strip is left as such. However, you can also set it so that the tabs are stretched to fill out the right extent of the strip, if necessary, or you can set it so that all tabs have the same width.

TabStrip.getTabCount

Syntax
public final int getTabCount();
Return Value

Returns the number of valid tabs.

Description

Retrieves the number of tabs in the strip.

TabStrip.getTabRect

Syntax
public final Rectangle getTabRect( int index );
Parameters
index
The index to get the bouding rectangle for.
Return Value

Returns the rectangle that identifies the bounds for the tab.

Description

Retrieves the bounding rectangle for the given tab in the TabStrip.

TabStrip.getTabs

Syntax
public final Object[] getTabs();
Return Value

Returns an array of items in the TabStrip. The first item is the 0th element, and the last item in the TabStrip is last in the array.

Description

Retrieves an Object array containing all the items in the TabStrip.

TabStrip.getTabStyle

Syntax
public final int getTabStyle();
Return Value

Returns one of the following integer values:

Description

Indicates whether the tabs in the TabStrip look like regular tabs as seen in property sheet applications, or if they look like butttons, as seen in the Windows 95 taskbar.

TabStrip.getTabText

Syntax
public final String getTabText( int index );
Parameters
index
The tab index.
Return Value

Returns the text of the tab.

Description

Retrieves the text for the given tab.

TabStrip.insertTab

Syntax
public final int insertTab( int index, Object item );
Parameters
index
The zero-based index of where the item should be inserted.
item
The item you want inserted.
Description

Adds a tab to the TabStrip, but in a location you specify, as opposed to the end of the list.

TabStrip.recreateHandle

Syntax
public void recreateHandle();
Description

Ovveride this to guarantee that the tabs are re-created when appropriate.

TabStrip.removeAll

Syntax
public void removeAll();
Description

Removes all tabs from the TabStrip. All values and data are discarded.

TabStrip.removeOnDrawItem

Syntax
public final void removeOnDrawItem( DrawItemEventHandler value );
Parameters
value
The event handler to be removed.
Description

Removes the given handler for the OnDrawItem event. If there are duplicate entries, all handlers are removed.

TabStrip.removeOnSelectionChange

Syntax
public final void removeOnSelectionChange( EventHandler value );
Parameters
value
The event handler to be removed.
Description

Removes the given handler for the OnSelectionChange event. If there are duplicate entries, all handlers are removed.

TabStrip.removeTab

Syntax
public void removeTab( int index );
Parameters
index
The index of the tab to remove.
Description

Removes the tab at the given index of the TabStrip. The tab and its data are discarded.

TabStrip.setDisplayRectSize

Syntax 1
public final void setDisplayRectSize( int width, int height );
Parameters
width
The new desired display width. The size of the tabstrip will be adjusted to reflect this.
height
The new desired display height. The size of the tabstrip will be adjusted to reflect this.
Description

Sets the size of the tabstrip based on a desired size for the display rectangle. Note that this is only guaranteed to be valid until tabs are added or removed. After that, the display size can change when the number of visible rows changes. [Note: zero tabs == zero rows]



Syntax 2
public final void setDisplayRectSize( Point p );
Parameters
p
The new desired display size. The size of the tabstrip will be adjusted to reflect this.
Description

Sets the size of the tabstrip based on a desired size for the display rectangle. Note that this is guaranteed to be valid only until tabs are added or removed. After that, the display size can change when the number of visible rows changes. [Note: zero tabs == zero rows]

TabStrip.setDrawStyle

Syntax
public final void setDrawStyle( int value );
Parameters
value
Set one of the following values:
  • [Tab]Drawstyle.Normal indicates that Windows paints the control.
  • [Tab]DrawStyle.OwnerDrawFixed indicates that an event is fired whenever an item needs to be drawn.
Description

Indicates whether the individual tabs are painted by Windows or by the end user. If the latter, an OnDrawItem event is fired whenever an item needs to be painted. All items must still be the same height.

TabStrip.setItemSize

Syntax
public final void setItemSize( Point size );
Description

Topic under construction.

TabStrip.setMultiline

Syntax
public final void setMultiline( boolean value );
Parameters
value
Indicates whether more than one row should be allowed.
Description

Indicates whether there can be more than one row of tabs. By default (when this property is false), if there are more tabs than available display space, arrows are shown to let the user navigate between the extra tabs, but only one row is shown. If this property is set to true, then Windows spills extra tabs over onto second rows.

TabStrip.setPadding

Syntax
public final void setPadding( Point value );
Parameters
A
Point object in which the width contains the horizontal padding and the height contains the vertical padding.
Description

Sets the amount of padding around the items in the individual tabs. You can specify both horizontal and vertical padding.

TabStrip.setSelectedIndex

Syntax
public final void setSelectedIndex( int index );
Parameters
index
The index of tab to select.
Description

Sets the tab at the supplied index as being the selected tab in the strip.

TabStrip.setSizeMode

Syntax
public final void setSizeMode( int value );
Parameters
value
Set one of the following values:
  • SizeMode.Normal indicates that tabs are only as wide as they need to be.
  • SizeMode.FillToRight indicates that tabs at least extend to the right extent of the strip.
  • SizeMode.Fixed indicates that all tabs are the same width.
Description

Sets the size mode. By default, tabs are big enough to display their text, and any space on the right of the strip is left as such. However, you can also set it so that the tabs are stretched to fill out the right extent of the strip, if necessary, or you can set it so that all tabs have the same width.

TabStrip.setTabs

Syntax
public final void setTabs( Object[] value );
Parameters
value
An array of objects that will be the new tabs in the strip.
Description

Sets all the tabs in the TabStrip at once by passing in an array with all their values. All old values in the TabStrip are discarded and lost.

TabStrip.setTabStyle

Syntax
public final void setTabStyle( int value );
Parameters
value
Set one of the following values:
  • TabStyle.Tabs indicates they are painted as normal tabs.
  • TabStyle.Buttons indicates they are painted like taskbar buttons.
Description

Indicates whether the tabs in the TabStrip look like regular tabs as seen in property sheet applications, or if they look like butttons, as seen in the Windows 95 taskbar.

TabStrip.setTabText

Syntax
public final void setTabText( int index, String value );
Parameters
index
The tab index.
value
The string to change the text to.
Description

Sets the text for the given tab.