com.sun.lwuit
Class Tabs

java.lang.Object
  extended by com.sun.lwuit.Component
      extended by com.sun.lwuit.Container
          extended by com.sun.lwuit.Tabs
All Implemented Interfaces:
Animation, StyleListener

public class Tabs
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 Tabs 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 Tabs 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.lwuit.Component
BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, LEFT, RIGHT, TOP
 
Constructor Summary
Tabs()
          Creates an empty TabbedPane with a default tab placement of Component.TOP.
Tabs(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(Button tab, Component component)
          Adds a component represented by a button.
 void addTab(java.lang.String title, Component component)
          Adds a component represented by a title and no icon.
 void addTab(java.lang.String title, Image icon, Component component)
          Adds a component represented by a title and/or icon, either of which can be null.
 void addTabsFocusListener(FocusListener listener)
          Adds a focus listener to the tabs buttons
 boolean animate()
          Allows the animation to reduce "repaint" calls when it returns false.
protected  void deinitialize()
          Invoked to indicate that the component initialization is being reversed since the component was detached from the container hierarchy.
 Container getContentPane()
          This method retrieves the Tabs content pane
 java.lang.String[] getPropertyNames()
          A component may expose mutable property names for a UI designer to manipulate, this API is designed for usage internally by the GUI builder code
 java.lang.Class[] getPropertyTypes()
          Matches the property names method (see that method for further details).
 java.lang.Object getPropertyValue(java.lang.String name)
          Returns the current value of the property name, this method is used by the GUI builder
 Component getSelectedComponent()
          Returns the component associated with the tab at the given index
 int getSelectedIndex()
          Returns the currently selected index for this tabbedpane.
 Component getTabComponentAt(int index)
          Returns the tab at index.
 int getTabCount()
          Returns the number of tabs in this tabbedpane.
 Image getTabIcon(int index)
          Returns the icon of the tab at the given index
 int getTabPlacement()
          Returns the placement of the tabs for this tabbedpane.
 Container getTabsContainer()
          This method retrieves the Tabs buttons Container
 Image getTabSelectedIcon(int index)
          Returns the icon of the tab at the given index
 int getTabTextPosition()
          Returns The position of the text relative to the icon
 java.lang.String getTabTitle(int index)
          Returns the title of the tab at the given index
 void hideTabs()
          Hide the tabs bar
 int indexOfComponent(Component component)
          Returns the index of the tab for the specified component.
protected  void initComponent()
          Allows subclasses to bind functionality that relies on fully initialized and "ready for action" component state
 void insertTab(Button tab, Component component, int index)
          Inserts a component, at index, represented by a button Uses java.util.Vector internally, see insertElementAt for details of insertion conventions.
 void insertTab(java.lang.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.
 boolean isChangeTabContainerStyleOnFocus()
          Indicates that the tabs container should have its style changed to the selected style when one of the tabs has focus this allows incorporating it into the theme of the application
 boolean isChangeTabOnFocus()
          Indicates that a tab should change when the focus changes without the user physically pressing a button
 boolean isSwipeActivated()
          Returns true if the swipe between tabs is activated, this is relevant for touch devices only
 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 removeTabsFocusListener(FocusListener listener)
          Removes a foucs Listener from the tabs buttons
 void setChangeTabContainerStyleOnFocus(boolean changeTabContainerStyleOnFocus)
          Indicates that the tabs container should have its style changed to the selected style when one of the tabs has focus this allows incorporating it into the theme of the application
 void setChangeTabOnFocus(boolean changeTabOnFocus)
          Indicates that a tab should change when the focus changes without the user physically pressing a button
 java.lang.String setPropertyValue(java.lang.String name, java.lang.Object value)
          Sets a new value to the given property, returns an error message if failed and null if successful.
 void setSelectedIndex(int index)
          Sets the selected index for this tabbedpane.
 void setSwipeActivated(boolean swipeActivated)
          Setter method for swipe mode
 void setTabPlacement(int tabPlacement)
          Sets the tab placement for this tabbedpane.
 void setTabSelectedIcon(int index, Image icon)
          Sets the selected icon of the tab at the given index
 void setTabTextPosition(int textPosition)
          Sets the position of the text relative to the icon if exists
 void setTabTitle(java.lang.String title, Image icon, int index)
          Updates the information about the tab details
 void showTabs()
          Show the tabs bar if it was hidden
 java.lang.String toString()
          Overriden to return a useful value for debugging purposes
 
Methods inherited from class com.sun.lwuit.Container
addComponent, addComponent, addComponent, addComponent, animateLayout, animateLayoutAndWait, applyRTL, calcPreferredSize, contains, dragInitiated, drop, findFirstFocusable, flushReplace, getBottomGap, getComponentAt, getComponentAt, getComponentCount, getComponentIndex, getGridPosX, getGridPosY, getLayout, getLayoutHeight, getLayoutWidth, getLeadComponent, getLeadParent, getScrollIncrement, getSideGap, invalidate, isEnabled, isScrollableX, isScrollableY, keyPressed, keyReleased, layoutContainer, paint, paintBackground, paintGlass, paramString, pointerHover, pointerPressed, removeAll, removeComponent, replace, replace, replaceAndWait, replaceAndWait, replaceAndWait, revalidate, scrollComponentToVisible, setCellRenderer, setEnabled, setLayout, setLeadComponent, setScrollable, setScrollableX, setScrollableY, setScrollIncrement, setShouldCalcPreferredSize, setShouldLayout
 
Methods inherited from class com.sun.lwuit.Component
addFocusListener, calcScrollSize, contains, deinitializeCustomStyle, dragEnter, dragExit, draggingOver, drawDraggedImage, fireClicked, focusGained, focusLost, getAbsoluteX, getAbsoluteY, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentForm, getDirtyRegion, getDisabledStyle, getDragImage, getHeight, getLabelForComponent, getName, getNextFocusDown, getNextFocusLeft, getNextFocusRight, getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW, getPressedStyle, getScrollAnimationSpeed, getScrollDimension, getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText, getSelectedRect, getSelectedStyle, getStyle, getTensileLength, getUIID, getUnselectedStyle, getWidth, getVisibleBounds, getX, getY, growShrink, handlesInput, hasFocus, initCustomStyle, installDefaultPainter, isAlwaysTensile, isDragActivated, isDragAndDropOperation, isDraggable, isDropTarget, isFlatten, isFocusable, isGrabsPointerEvents, isHideInPortrait, isInitialized, isRTL, isScrollable, isScrollVisible, isSelectableInteraction, isSmoothScrolling, isSnapToGrid, isTactileTouch, isTactileTouch, isTensileDragEnabled, isVisible, keyRepeated, laidOut, longKeyPress, longPointerPress, paintBackgrounds, paintBorder, paintComponent, paintComponent, paintLock, paintLockRelease, paintScrollbars, paintScrollbarX, paintScrollbarY, pointerDragged, pointerDragged, pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased, pointerReleased, putClientProperty, refreshTheme, removeFocusListener, repaint, repaint, requestFocus, scrollRectToVisible, scrollRectToVisible, setAlwaysTensile, setDirtyRegion, setDisabledStyle, setDraggable, setDropTarget, setFlatten, setFocus, setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHideInPortrait, setInitialized, setIsScrollVisible, setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft, setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize, setPreferredW, setPressedStyle, setRTL, setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize, setScrollVisible, setScrollX, setScrollY, setSelectCommandText, setSelectedStyle, setSize, setSmoothScrolling, setSnapToGrid, setTactileTouch, setTensileDragEnabled, setTensileLength, setUIID, setUnselectedStyle, setWidth, setVisible, setX, setY, styleChanged
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Tabs

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


Tabs

public Tabs(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

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

deinitialize

protected void deinitialize()
Description copied from class: Component
Invoked to indicate that the component initialization is being reversed since the component was detached from the container hierarchy. This allows the component to deregister animators and cleanup after itself. This method is the opposite of the initComponent() method.

Overrides:
deinitialize in class Component

initComponent

protected void initComponent()
Description copied from class: Component
Allows subclasses to bind functionality that relies on fully initialized and "ready for action" component state

Overrides:
initComponent in class Component

animate

public boolean animate()
Description copied from interface: Animation
Allows the animation to reduce "repaint" calls when it returns false. It is called once for every frame. Frames are defined by the Display class.

Specified by:
animate in interface Animation
Overrides:
animate in class Component
Returns:
true if a repaint is desired or false if no repaint is necessary

setTabTextPosition

public void setTabTextPosition(int textPosition)
Sets the position of the text relative to the icon if exists

Parameters:
textPosition - alignment value (LEFT, RIGHT, BOTTOM or TOP)
See Also:
Component.LEFT, Component.RIGHT, Component.BOTTOM, Component.TOP

getTabTextPosition

public int getTabTextPosition()
Returns The position of the text relative to the icon

Returns:
The position of the text relative to the icon, one of: LEFT, RIGHT, BOTTOM, TOP
See Also:
Component.LEFT, Component.RIGHT, Component.BOTTOM, Component.TOP

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

addTab

public void addTab(java.lang.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.lwuit.Image, com.sun.lwuit.Component, int), removeTabAt(int)

addTab

public void addTab(java.lang.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.lwuit.Image, com.sun.lwuit.Component, int), removeTabAt(int)

addTab

public void addTab(Button tab,
                   Component component)
Adds a component represented by a button. Cover method for insertTab. The Button styling will be associated with "Tab" UIID.

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

insertTab

public void insertTab(java.lang.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.lwuit.Image, com.sun.lwuit.Component), removeTabAt(int)

insertTab

public void insertTab(Button tab,
                      Component component,
                      int index)
Inserts a component, at index, represented by a button Uses java.util.Vector internally, see insertElementAt for details of insertion conventions. The Button styling will be associated with "Tab" UIID.

Parameters:
tab - represents the tab on top
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.lwuit.Image, com.sun.lwuit.Component), removeTabAt(int)

setTabTitle

public void setTabTitle(java.lang.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

getTabTitle

public java.lang.String getTabTitle(int index)
Returns the title of the tab at the given index

Parameters:
index - index for the tab
Returns:
label of the tab at the given index

getTabIcon

public Image getTabIcon(int index)
Returns the icon of the tab at the given index

Parameters:
index - index for the tab
Returns:
icon of the tab at the given index

getTabSelectedIcon

public Image getTabSelectedIcon(int index)
Returns the icon of the tab at the given index

Parameters:
index - index for the tab
Returns:
icon of the tab at the given index

setTabSelectedIcon

public void setTabSelectedIcon(int index,
                               Image icon)
Sets the selected icon of the tab at the given index

Parameters:
index - index for the tab
icon - of the tab at the given index

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:
java.lang.IndexOutOfBoundsException - if index is out of range (index < 0 || index >= tab count)
See Also:
addTab(java.lang.String, com.sun.lwuit.Image, com.sun.lwuit.Component), insertTab(java.lang.String, com.sun.lwuit.Image, com.sun.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 component at the given tab location
Throws:
java.lang.IndexOutOfBoundsException - if index is out of range (index < 0 || index >= tab count)
See Also:
addTab(java.lang.String, com.sun.lwuit.Image, com.sun.lwuit.Component), insertTab(java.lang.String, com.sun.lwuit.Image, com.sun.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

getSelectedComponent

public Component getSelectedComponent()
Returns the component associated with the tab at the given index

Returns:
the component is now showing in the tabbed pane

addTabsFocusListener

public void addTabsFocusListener(FocusListener listener)
Adds a focus listener to the tabs buttons

Parameters:
listener - FocusListener

removeTabsFocusListener

public void removeTabsFocusListener(FocusListener listener)
Removes a foucs Listener from the tabs buttons

Parameters:
listener - FocusListener

toString

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

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

getTabPlacement

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

Returns:
the tab placement value
See Also:
setTabPlacement(int)

getContentPane

public Container getContentPane()
This method retrieves the Tabs content pane

Returns:
the content pane Container

getTabsContainer

public Container getTabsContainer()
This method retrieves the Tabs buttons Container

Returns:
the Tabs Container

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:
java.lang.IndexOutOfBoundsException - if index is out of range (index < 0 || index >= tab count)

hideTabs

public void hideTabs()
Hide the tabs bar


showTabs

public void showTabs()
Show the tabs bar if it was hidden


isSwipeActivated

public boolean isSwipeActivated()
Returns true if the swipe between tabs is activated, this is relevant for touch devices only

Returns:
swipe activated flag

setSwipeActivated

public void setSwipeActivated(boolean swipeActivated)
Setter method for swipe mode

Parameters:
swipeActivated -

isChangeTabOnFocus

public boolean isChangeTabOnFocus()
Indicates that a tab should change when the focus changes without the user physically pressing a button

Returns:
the changeTabOnFocus

setChangeTabOnFocus

public void setChangeTabOnFocus(boolean changeTabOnFocus)
Indicates that a tab should change when the focus changes without the user physically pressing a button

Parameters:
changeTabOnFocus - the changeTabOnFocus to set

isChangeTabContainerStyleOnFocus

public boolean isChangeTabContainerStyleOnFocus()
Indicates that the tabs container should have its style changed to the selected style when one of the tabs has focus this allows incorporating it into the theme of the application

Returns:
the changeTabContainerStyleOnFocus

setChangeTabContainerStyleOnFocus

public void setChangeTabContainerStyleOnFocus(boolean changeTabContainerStyleOnFocus)
Indicates that the tabs container should have its style changed to the selected style when one of the tabs has focus this allows incorporating it into the theme of the application

Parameters:
changeTabContainerStyleOnFocus - the changeTabContainerStyleOnFocus to set

getPropertyNames

public java.lang.String[] getPropertyNames()
Description copied from class: Component
A component may expose mutable property names for a UI designer to manipulate, this API is designed for usage internally by the GUI builder code

Overrides:
getPropertyNames in class Component
Returns:
the property names allowing mutation

getPropertyTypes

public java.lang.Class[] getPropertyTypes()
Description copied from class: Component
Matches the property names method (see that method for further details).

Overrides:
getPropertyTypes in class Component
Returns:
the types of the properties

getPropertyValue

public java.lang.Object getPropertyValue(java.lang.String name)
Description copied from class: Component
Returns the current value of the property name, this method is used by the GUI builder

Overrides:
getPropertyValue in class Component
Parameters:
name - the name of the property
Returns:
the value of said property

setPropertyValue

public java.lang.String setPropertyValue(java.lang.String name,
                                         java.lang.Object value)
Description copied from class: Component
Sets a new value to the given property, returns an error message if failed and null if successful. Notice that some builtin properties such as "$designMode" might be sent to components to indicate application state.

Overrides:
setPropertyValue in class Component
Parameters:
name - the name of the property
value - new value for the property
Returns:
error message or null