Java DTV API 1.3
18-Nov-2009

com.sun.dtv.lwuit
Class TabbedPane

java.lang.Object
  extended by com.sun.dtv.lwuit.Component
      extended by com.sun.dtv.lwuit.Container
          extended by com.sun.dtv.lwuit.TabbedPane
All Implemented Interfaces:
Animation, StyleListener, Animated, MatteEnabled

public class TabbedPane
extends Container

A component that lets the user switch between a group of components by clicking on a tab with a given title and/or icon.

Tabs/components are added to a TabbedPane object by using the addTab and insertTab methods. A tab is represented by an index corresponding to the position it was added in, where the first tab has an index equal to 0 and the last tab has an index equal to the tab count minus 1.

The TabbedPane uses a SingleSelectionModel to represent the set of tab indices and the currently selected index. If the tab count is greater than 0, then there will always be a selected index, which by default will be initialized to the first tab. If the tab count is 0, then the selected index will be -1.


Field Summary
 
Fields inherited from class com.sun.dtv.lwuit.Component
BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, LEFT, RIGHT, TOP
 
Fields inherited from interface com.sun.dtv.ui.Animated
ALTERNATING, LOOP, REPEATING
 
Constructor Summary
TabbedPane()
          Creates an empty TabbedPane with a default tab placement of Component.TOP.
TabbedPane(int tabPlacement)
          Creates an empty TabbedPane with the specified tab placement of either: Component.TOP, Component.BOTTOM, Component.LEFT, or Component.RIGHT.
 
Method Summary
 void addTab(String title, Component component)
          Adds a component represented by a title and no icon.
 void addTab(String title, Image icon, Component component)
          Adds a component represented by a title and/or icon, either of which can be null.
 void addTabsListener(SelectionListener listener)
          This method adds a listener to the tabs.
 int getSelectedIndex()
          Returns the currently selected index for this tabbedpane.
 int getTabbedPaneBorderWidth()
          The TabbedPane surrounded border width.
 Component getTabComponentAt(int index)
          Returns the tab at index.
 int getTabCount()
          Returns the number of tabs in this tabbedpane.
 int getTabPlacement()
          Returns the placement of the tabs for this tabbedpane.
 Transition getTransitionLeft()
          Indicates the transition to use when switching between tabs from right to left.
 Transition getTransitionRight()
          Indicates the transition to use when switching between tabs from left to right.
 int indexOfComponent(Component component)
          Returns the index of the tab for the specified component.
 void insertTab(String title, Image icon, Component component, int index)
          Inserts a component, at index, represented by a title and/or icon, either of which may be null.
 void paint(Graphics g)
          This method paints the Component on the screen, it should be overriden by subclasses to perform custom drawing or invoke the UI API's to let the PLAF perform the rendering.
 void refreshTheme()
          Makes sure the component is up to date with the current style object.
 void removeTabAt(int index)
          Removes the tab at index.
 void requestFocus()
          Changes the current component to the focused component, will work only for a component that belongs to a parent form.
 void setFocusable(boolean b)
          A simple setter to determine if this Component can get focused.
 void setPadding(int orientation, int gap)
          Sets the padding of the tabbed pane.
 void setPadding(int top, int bottom, int left, int right)
          Sets the padding of the tabbed pane.
 void setSelectedIndex(int index)
          Sets the selected index for this tabbedpane.
 void setStyle(Style style)
          Changes the Component Style by replacing the Component Style with the given Style.
 void setTabbedPaneBorderWidth(int tabbedPaneBorderWidth)
          Setting the TabbedPane surrounded border width.
 void setTabPlacement(int tabPlacement)
          Sets the tab placement for this tabbedpane.
 void setTabTitle(String title, Image icon, int index)
          Updates the information about the tab details.
 void setTabTitlePrototype(String title)
          The prototype is optionally used in calculating the size of an individual tab and is recommended for performance reasons.
 void setTransitionLeft(Transition transitionLeft)
          Indicates the transition to use when switching between tabs from right to left.
 void setTransitionRight(Transition transitionRight)
          Indicates the transition to use when switching between tabs from left to right.
 String toString()
          Overriden to return a useful value for debugging purposes.
 
Methods inherited from class com.sun.dtv.lwuit.Container
addComponent, addComponent, addComponent, contains, doLayout, getComponentAt, getComponentAt, getComponentCount, getComponentIndex, getLayout, getLayoutHeight, getLayoutWidth, getMatte, invalidate, isScrollableX, isScrollableY, layoutContainer, pointerPressed, removeAll, removeComponent, replace, revalidate, scrollComponentToVisible, setCellRenderer, setLayout, setMatte, setScrollable, setScrollableX, setScrollableY
 
Methods inherited from class com.sun.dtv.lwuit.Component
addFocusListener, animate, calcPreferredSize, contains, deinitialize, getAbsoluteX, getAbsoluteY, getAnimationMode, getBaseline, getBaselineResizeBehavior, getBottomGap, getBounds, getClientProperty, getComponentForm, getDelay, getHeight, getNextFocusDown, getNextFocusLeft, getNextFocusRight, getNextFocusUp, getParent, getPosition, getPreferredSize, getRepetitionMode, getScrollAnimationSpeed, getScrollX, getScrollY, getSideGap, getStyle, getUIID, getWidth, getX, getY, handlesInput, hasFocus, initialize, isEnabled, isFocusable, isFocusPainted, isInitialized, isRunning, isScrollVisible, isSmoothScrolling, isVisible, jumpTo, keyPressed, keyReleased, keyRepeated, longKeyPress, paintBackgrounds, paintComponent, paintComponent, pointerDragged, pointerReleased, putClientProperty, removeFocusListener, repaint, repaint, scrollRectToVisible, setAnimationMode, setDelay, setEnabled, setFocus, setFocusPainted, setHandlesInput, setHeight, setInitialized, setIsScrollVisible, setNextFocusDown, setNextFocusLeft, setNextFocusRight, setNextFocusUp, setPreferredSize, setRepetitionMode, setScrollAnimationSpeed, setScrollX, setScrollY, setShouldCalcPreferredSize, setSize, setSmoothScrolling, setUIID, setVisible, setWidth, setX, setY, start, stop, styleChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TabbedPane

public TabbedPane()
Creates an empty TabbedPane with a default tab placement of Component.TOP.


TabbedPane

public TabbedPane(int tabPlacement)
Creates an empty TabbedPane with the specified tab placement of either: Component.TOP, Component.BOTTOM, Component.LEFT, or Component.RIGHT.

Parameters:
tabPlacement - the placement for the tabs relative to the content
Method Detail

setTransitionLeft

public void setTransitionLeft(Transition transitionLeft)
Indicates the transition to use when switching between tabs from right to left.

Parameters:
transitionLeft - transition to use when switching tabs or null to avoid transition
See Also:
getTransitionLeft()

getTransitionLeft

public Transition getTransitionLeft()
Indicates the transition to use when switching between tabs from right to left.

Returns:
transition to use when switching tabs
See Also:
setTransitionLeft(com.sun.dtv.lwuit.animations.Transition)

setTransitionRight

public void setTransitionRight(Transition transitionRight)
Indicates the transition to use when switching between tabs from left to right.

Parameters:
transitionRight - transition to use when switching tabs or null to avoid transition
See Also:
getTransitionRight()

getTransitionRight

public Transition getTransitionRight()
Indicates the transition to use when switching between tabs from left to right.

Returns:
transition to use when switching tabs
See Also:
setTransitionRight(com.sun.dtv.lwuit.animations.Transition)

setFocusable

public void setFocusable(boolean b)
Description copied from class: Component
A simple setter to determine if this Component can get focused.

Overrides:
setFocusable in class Component
Parameters:
b - indicate whether this component can get focused

addTabsListener

public void addTabsListener(SelectionListener listener)
This method adds a listener to the tabs.

Parameters:
listener - a selection listener to gets the selection events

requestFocus

public void requestFocus()
Description copied from class: Component
Changes the current component to the focused component, will work only for a component that belongs to a parent form.

Overrides:
requestFocus in class Component

setTabPlacement

public void setTabPlacement(int tabPlacement)
Sets the tab placement for this tabbedpane. Possible values are: The default value, if not set, is Component.TOP.

Parameters:
tabPlacement - the placement for the tabs relative to the content
See Also:
getTabPlacement()

addTab

public void addTab(String title,
                   Image icon,
                   Component component)
Adds a component represented by a title and/or icon, either of which can be null. Cover method for insertTab.

Parameters:
title - the title to be displayed in this tab
icon - the icon to be displayed in this tab
component - the component to be displayed when this tab is clicked
See Also:
insertTab(java.lang.String, com.sun.dtv.lwuit.Image, com.sun.dtv.lwuit.Component, int), removeTabAt(int)

addTab

public void addTab(String title,
                   Component component)
Adds a component represented by a title and no icon. Cover method for insertTab.

Parameters:
title - the title to be displayed in this tab
component - the component to be displayed when this tab is clicked
See Also:
insertTab(java.lang.String, com.sun.dtv.lwuit.Image, com.sun.dtv.lwuit.Component, int), removeTabAt(int)

insertTab

public void insertTab(String title,
                      Image icon,
                      Component component,
                      int index)
Inserts a component, at index, represented by a title and/or icon, either of which may be null. Uses java.util.Vector internally, see insertElementAt for details of insertion conventions.

Parameters:
title - the title to be displayed in this tab
icon - the icon to be displayed in this tab
component - The component to be displayed when this tab is clicked.
index - the position to insert this new tab
See Also:
addTab(java.lang.String, com.sun.dtv.lwuit.Image, com.sun.dtv.lwuit.Component), removeTabAt(int)

setTabTitle

public void setTabTitle(String title,
                        Image icon,
                        int index)
Updates the information about the tab details.

Parameters:
title - the title to be displayed in this tab
icon - the icon to be displayed in this tab
index - the position to insert this new tab

removeTabAt

public void removeTabAt(int index)
Removes the tab at index. After the component associated with index is removed, its visibility is reset to true to ensure it will be visible if added to other containers.

Parameters:
index - the index of the tab to be removed
Throws:
IndexOutOfBoundsException - if index is out of range (index < 0 || index >= tab count)
See Also:
addTab(java.lang.String, com.sun.dtv.lwuit.Image, com.sun.dtv.lwuit.Component), insertTab(java.lang.String, com.sun.dtv.lwuit.Image, com.sun.dtv.lwuit.Component, int)

getTabComponentAt

public Component getTabComponentAt(int index)
Returns the tab at index.

Parameters:
index - the index of the tab to be removed
Returns:
the tab at index
Throws:
IndexOutOfBoundsException - if index is out of range (index < 0 || index >= tab count)
See Also:
addTab(java.lang.String, com.sun.dtv.lwuit.Image, com.sun.dtv.lwuit.Component), insertTab(java.lang.String, com.sun.dtv.lwuit.Image, com.sun.dtv.lwuit.Component, int)

indexOfComponent

public int indexOfComponent(Component component)
Returns the index of the tab for the specified component. Returns -1 if there is no tab for this component.

Parameters:
component - the component for the tab
Returns:
the first tab which matches this component, or -1 if there is no tab for this component

getTabCount

public int getTabCount()
Returns the number of tabs in this tabbedpane.

Returns:
an integer specifying the number of tabbed pages

getSelectedIndex

public int getSelectedIndex()
Returns the currently selected index for this tabbedpane. Returns -1 if there is no currently selected tab.

Returns:
the index of the selected tab
See Also:
setSelectedIndex(int)

setTabTitlePrototype

public void setTabTitlePrototype(String title)
The prototype is optionally used in calculating the size of an individual tab and is recommended for performance reasons. You should invoke it with a String representing the width/height which will be used to calculate the size required for each element in the list.\

This operation is not essential and if it isn't invoked the size of the first few tabs is used to determine the overall size of a tab.

This allows the size calculations to work across look and feels and allows developers to predetermine size for the tabs.

e.g. For tabs which you would like to always be 5 characters wide you can use a prototype "XXXXX" which would use the preferred size of the XXXXX String to determine the size of the tabs..

Parameters:
title - a string to determine the size.

toString

public String toString()
Description copied from class: Component
Overriden to return a useful value for debugging purposes. Overrides Object.toString.

Overrides:
toString in class Component
Returns:
a string representation of this component

paint

public void paint(Graphics g)
Description copied from class: Component
This method paints the Component on the screen, it should be overriden by subclasses to perform custom drawing or invoke the UI API's to let the PLAF perform the rendering.

Specified by:
paint in interface Animation
Overrides:
paint in class Container
Parameters:
g - the component graphics

setStyle

public void setStyle(Style style)
Description copied from class: Component
Changes the Component Style by replacing the Component Style with the given Style.

Overrides:
setStyle in class Component
Parameters:
style - the component Style object
See Also:
Component.getStyle()

refreshTheme

public void refreshTheme()
Description copied from class: Component
Makes sure the component is up to date with the current style object.

Overrides:
refreshTheme in class Container

getTabPlacement

public int getTabPlacement()
Returns the placement of the tabs for this tabbedpane.

Returns:
the placement of the tabs for this tabbedpane
See Also:
setTabPlacement(int)

getTabbedPaneBorderWidth

public int getTabbedPaneBorderWidth()
The TabbedPane surrounded border width.

Returns:
The TabbedPane surrounded border width
See Also:
setTabbedPaneBorderWidth(int)

setTabbedPaneBorderWidth

public void setTabbedPaneBorderWidth(int tabbedPaneBorderWidth)
Setting the TabbedPane surrounded border width.

Parameters:
tabbedPaneBorderWidth - TabbedPane surrounded border width
See Also:
getTabbedPaneBorderWidth()

setPadding

public void setPadding(int top,
                       int bottom,
                       int left,
                       int right)
Sets the padding of the tabbed pane.

Parameters:
top - value for top
bottom - value for bottom
left - value for left side
right - value for right side

setPadding

public void setPadding(int orientation,
                       int gap)
Sets the padding of the tabbed pane.

Parameters:
orientation - orientation of the padding
gap - gap of the padding

setSelectedIndex

public void setSelectedIndex(int index)
Sets the selected index for this tabbedpane. The index must be a valid tab index.

Parameters:
index - the index to be selected
Throws:
IndexOutOfBoundsException - if index is out of range (index < 0 || index >= tab count)
See Also:
getSelectedIndex()

Java DTV API 1.3
18-Nov-2009

Copyright © 2008-2009 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, California 95054, U.S.A. All rights reserved.

U.S. Government Rights - Commercial software. Government users are subject to the Sun Microsystems, Inc. standard license agreement and applicable provisions of the FAR and its supplements. Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries.Products covered by and information contained in this service manual are controlled by U.S. Export Control laws and may be subject to the export or import laws in other countries. Nuclear, missile, chemical biological weapons or nuclear maritime end uses or end users, whether direct or indirect, are strictly prohibited. Export or reexport to countries subject to U.S. embargo or to entities identified on U.S. export exclusion lists, including, but not limited to, the denied persons and specially designated nationals lists is strictly prohibited.

DOCUMENTATION IS PROVIDED AS IS AND ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD TO BE LEGALLY INVALID.

Use of this document is subject to license terms.