public class Tabs extends Container
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.
BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X, DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y, DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X, DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP
Constructor and Description |
---|
Tabs()
Creates an empty
TabbedPane with a default
tab placement of Component.TOP . |
Tabs(int tabP)
Creates an empty
TabbedPane with the specified tab placement
of either: Component.TOP , Component.BOTTOM ,
Component.LEFT , or Component.RIGHT . |
Modifier and Type | Method and Description |
---|---|
void |
addSelectionListener(SelectionListener listener)
Adds a selection listener to the tabs.
|
void |
addTab(Button tab,
Component component)
Deprecated.
should use radio button as an argument
|
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 |
addTabsFocusListener(FocusListener listener)
Deprecated.
use addSelectionListener instead
|
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
|
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
|
String[] |
getPropertyTypeNames()
This method is here to workaround an XMLVM array type bug where property types aren't
identified properly, it returns the names of the types using the following type names:
String,int,double,long,byte,short,char,String[],String[][],byte[],Image,Image[],Object[],ListModel,ListCellRenderer
|
Class[] |
getPropertyTypes()
Matches the property names method (see that method for further details).
|
Object |
getPropertyValue(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
|
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
|
protected void |
initLaf(UIManager manager)
This method initializes the Component defaults constants
|
void |
insertTab(Button tab,
Component component,
int index)
Deprecated.
should use radio button as an argument
|
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 . |
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(boolean merge)
Makes sure the component is up to date with the current theme, ONLY INVOKE THIS METHOD IF YOU CHANGED THE THEME!
|
void |
removeSelectionListener(SelectionListener listener)
Removes a selection Listener from the tabs
|
void |
removeTabAt(int index)
Removes the tab at
index . |
void |
removeTabsFocusListener(FocusListener listener)
Deprecated.
use addSelectionListener instead
|
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
|
String |
setPropertyValue(String name,
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 |
setTabsContentGap(int tabsGap)
This method allows setting the Tabs content pane spacing (right and left),
This can be used to create an effect where the selected tab is smaller
and the right and left tabs are visible on the sides
|
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(String title,
Image icon,
int index)
Updates the information about the tab details
|
void |
showTabs()
Show the tabs bar if it was hidden
|
String |
toString()
Overriden to return a useful value for debugging purposes
|
addComponent, addComponent, addComponent, addComponent, animateHierarchy, animateHierarchyAndWait, animateHierarchyFade, animateHierarchyFadeAndWait, animateLayout, animateLayoutAndWait, animateLayoutFade, animateLayoutFadeAndWait, animateUnlayout, animateUnlayoutAndWait, applyRTL, calcPreferredSize, cancelRepaints, clearClientProperties, contains, createAnimateMotion, dragInitiated, drop, findFirstFocusable, fireClicked, flushReplace, forceRevalidate, getBottomGap, getClosestComponentTo, getComponentAt, getComponentAt, getComponentCount, getComponentIndex, getGridPosX, getGridPosY, getLayout, getLayoutHeight, getLayoutWidth, getLeadComponent, getLeadParent, getScrollIncrement, getSideGap, getUIManager, invalidate, isEnabled, isScrollableX, isScrollableY, isSelectableInteraction, keyPressed, keyReleased, layoutContainer, morph, morphAndWait, 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, setUIManager
addDragOverListener, addDropListener, addFocusListener, addPullToRefresh, bindProperty, calcScrollSize, contains, deinitializeCustomStyle, dragEnter, dragExit, draggingOver, drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY, getBaseline, getBaselineResizeBehavior, getBindablePropertyNames, getBindablePropertyTypes, getBorder, getBoundPropertyValue, getBounds, getClientProperty, getCloudBoundProperty, getCloudDestinationProperty, getComponentForm, getComponentState, getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage, getDragRegionStatus, getDragSpeed, getHeight, getLabelForComponent, getName, getNextFocusDown, getNextFocusLeft, getNextFocusRight, getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW, getPressedStyle, getScrollable, getScrollAnimationSpeed, getScrollDimension, getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText, getSelectedRect, getSelectedStyle, getStyle, getTensileLength, getUIID, getUnselectedStyle, getVisibleBounds, getWidth, getX, getY, growShrink, handlesInput, hasFocus, initCustomStyle, installDefaultPainter, isAlwaysTensile, isCellRenderer, isDragActivated, isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isFlatten, isFocusable, isGrabsPointerEvents, isHideInPortrait, isInClippingRegion, isInitialized, isRTL, isScrollable, isScrollVisible, isSmoothScrolling, isSnapToGrid, isStickyDrag, isTactileTouch, isTactileTouch, isTensileDragEnabled, isVisible, keyRepeated, laidOut, longKeyPress, longPointerPress, onScrollX, onScrollY, paintBackgrounds, paintBorder, paintComponent, paintComponent, paintLock, paintLockRelease, paintScrollbars, paintScrollbarX, paintScrollbarY, pinch, pointerDragged, pointerDragged, pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased, pointerReleased, putClientProperty, refreshTheme, refreshTheme, removeDragOverListener, removeDropListener, removeFocusListener, repaint, repaint, requestFocus, resetFocusable, scrollRectToVisible, scrollRectToVisible, setAlwaysTensile, setBoundPropertyValue, setCloudBoundProperty, setCloudDestinationProperty, setComponentState, 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, setVisible, setWidth, setX, setY, shouldBlockSideSwipe, styleChanged, unbindProperty
public Tabs()
TabbedPane
with a default
tab placement of Component.TOP
.public Tabs(int tabP)
TabbedPane
with the specified tab placement
of either: Component.TOP
, Component.BOTTOM
,
Component.LEFT
, or Component.RIGHT
.tabPlacement
- the placement for the tabs relative to the contentprotected void initLaf(UIManager manager)
Component
public void refreshTheme(boolean merge)
Component
refreshTheme
in class Container
merge
- indicates if the current styles should be merged with the new stylesprotected void deinitialize()
Component
deinitialize
in class Component
protected void initComponent()
Component
initComponent
in class Component
public boolean animate()
Animation
Display
class.public void setTabTextPosition(int textPosition)
textPosition
- alignment value (LEFT, RIGHT, BOTTOM or TOP)Component.LEFT
,
Component.RIGHT
,
Component.BOTTOM
,
Component.TOP
public int getTabTextPosition()
Component.LEFT
,
Component.RIGHT
,
Component.BOTTOM
,
Component.TOP
public void setTabPlacement(int tabPlacement)
Component.TOP
Component.BOTTOM
Component.LEFT
Component.RIGHT
Component.TOP
.tabPlacement
- the placement for the tabs relative to the contentpublic void addTab(String title, Image icon, Component component)
component
represented by a title
and/or icon
,
either of which can be null
.
Cover method for insertTab
.title
- the title to be displayed in this tabicon
- the icon to be displayed in this tabcomponent
- the component to be displayed when this tab is clickedinsertTab(java.lang.String, com.codename1.ui.Image, com.codename1.ui.Component, int)
,
removeTabAt(int)
public void addTab(String title, Component component)
component
represented by a title
and no icon
.
Cover method for insertTab
.title
- the title to be displayed in this tabcomponent
- the component to be displayed when this tab is clickedinsertTab(java.lang.String, com.codename1.ui.Image, com.codename1.ui.Component, int)
,
removeTabAt(int)
public void addTab(Button tab, Component component)
component
represented by a button
.
Cover method for insertTab
.
The Button styling will be associated with "Tab" UIID.tab
- represents the tab on topcomponent
- the component to be displayed when this tab is clickedinsertTab(java.lang.String, com.codename1.ui.Image, com.codename1.ui.Component, int)
,
removeTabAt(int)
public void insertTab(String title, Image icon, Component component, int index)
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.title
- the title to be displayed in this tabicon
- the icon to be displayed in this tabcomponent
- The component to be displayed when this tab is clicked.index
- the position to insert this new tabaddTab(java.lang.String, com.codename1.ui.Image, com.codename1.ui.Component)
,
removeTabAt(int)
public void insertTab(Button tab, Component component, int index)
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.tab
- represents the tab on topcomponent
- The component to be displayed when this tab is clicked.index
- the position to insert this new tabaddTab(java.lang.String, com.codename1.ui.Image, com.codename1.ui.Component)
,
removeTabAt(int)
public void setTabTitle(String title, Image icon, int index)
title
- the title to be displayed in this tabicon
- the icon to be displayed in this tabindex
- the position to insert this new tabpublic String getTabTitle(int index)
index
- index for the tabpublic Image getTabIcon(int index)
index
- index for the tabpublic Image getTabSelectedIcon(int index)
index
- index for the tabpublic void setTabSelectedIcon(int index, Image icon)
index
- index for the tabicon
- of the tab at the given indexpublic void removeTabAt(int index)
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.index
- the index of the tab to be removedIndexOutOfBoundsException
- if index is out of range
(index < 0 || index >= tab count)addTab(java.lang.String, com.codename1.ui.Image, com.codename1.ui.Component)
,
insertTab(java.lang.String, com.codename1.ui.Image, com.codename1.ui.Component, int)
public Component getTabComponentAt(int index)
index
.index
- the index of the tab to be removedIndexOutOfBoundsException
- if index is out of range
(index < 0 || index >= tab count)addTab(java.lang.String, com.codename1.ui.Image, com.codename1.ui.Component)
,
insertTab(java.lang.String, com.codename1.ui.Image, com.codename1.ui.Component, int)
public int indexOfComponent(Component component)
component
- the component for the tabpublic int getTabCount()
tabbedpane
.public int getSelectedIndex()
public Component getSelectedComponent()
public void addTabsFocusListener(FocusListener listener)
listener
- FocusListenerpublic void removeTabsFocusListener(FocusListener listener)
listener
- FocusListenerpublic void addSelectionListener(SelectionListener listener)
listener
- SelectionListenerpublic void removeSelectionListener(SelectionListener listener)
listener
- SelectionListenerpublic String toString()
Component
public int getTabPlacement()
setTabPlacement(int)
public Container getContentPane()
public Container getTabsContainer()
public void setSelectedIndex(int index)
index
- the index to be selectedIndexOutOfBoundsException
- if index is out of range
(index < 0 || index >= tab count)public void hideTabs()
public void showTabs()
public boolean isSwipeActivated()
public void setSwipeActivated(boolean swipeActivated)
swipeActivated
- public boolean isChangeTabOnFocus()
public void setChangeTabOnFocus(boolean changeTabOnFocus)
changeTabOnFocus
- the changeTabOnFocus to setpublic boolean isChangeTabContainerStyleOnFocus()
public void setChangeTabContainerStyleOnFocus(boolean changeTabContainerStyleOnFocus)
changeTabContainerStyleOnFocus
- the changeTabContainerStyleOnFocus to setpublic void setTabsContentGap(int tabsGap)
tabsGap
- the gap on the sides of the content in pixels, the value must
be positive.public String[] getPropertyNames()
Component
getPropertyNames
in class Component
public Class[] getPropertyTypes()
Component
getPropertyTypes
in class Component
public String[] getPropertyTypeNames()
Component
getPropertyTypeNames
in class Component
public Object getPropertyValue(String name)
Component
getPropertyValue
in class Component
name
- the name of the propertypublic String setPropertyValue(String name, Object value)
Component
setPropertyValue
in class Component
name
- the name of the propertyvalue
- new value for the property