Class Tab
This component collects the tab components. This means that the component has no visual display on the interface, it is only used to group tab page components. Please note that the tab page components cannot be placed on the interface directly, they must be placed through the tab component. Otherwise, neither the tab, or tab page component will not function properly.
Through the component, tab page components can be displayed. Only one tab page component can be displayed from a group. However, every tab will be visible on the top. By default, when displaying the first tab page component will be active, and have its contents displayed. If the user clicks on another tab, the currently active tab page will disappear, only it's clickable tab will remain, while the new tab page will be displayed.
With the help of this component, we can set the state of the assigned tab pages. By default, these tab pages appear on the upper side of the tab, but it can be modified to the left or right side. It is also possible to switch between the tab pages through code, either by using their index, or going forward or backward by one tab. Click handlers can also be placed on the individual tab pages, or the same handler can be set to all tab pages, so the event of the user changing pages can be handled.
Supported events:
AnimationStart
AnimationEnd
,
Drop
,
DragStart
,
DragEnd
- Since:
- 4.0
- Author:
- JBStrap
- See Also:
-
Field Summary
Fields inherited from class com.jbstrap.ui.Component
animation, attributes, backgroundColor, borderColor, color, defaultHotKeyHandler, handlers, hotKeys, styleClasses, textAlign, toolTip, toolTipPosition
-
Constructor Summary
ConstructorDescriptionTab()
Creates an empty, default tab component.Creates an empty tab component, with the specified tab typeCreates a tab component, with the specified tab type and tab pages.Creates a tab component, in the default state, with the specified tab pagesCreates an empty, default tab component with the specified ID.Creates an empty tab component, with the specified tab typeCreates a tab component, with the specified tab type and tab pages.Creates a tab component, in the default state, with the specified tab pages -
Method Summary
Modifier and TypeMethodDescriptionaddComponent
(Component<?> component) Adds a component to the tab component.addTabClickHandler
(int tabIndex, ClickEventHandler handler) Adds a tab page click handler (tab page change event) to the specified tab page.addTabClickHandler
(ClickEventHandler handler) Adds a tab page click handler (tab page change event).addTabPage
(TabPage tabPage) Adds the specified tab page to the tab componentaddTabPages
(TabPage... tabPages) Adds multiple tab pages to the tab componentGets the currently active tab page component.Gets the index of the currently selected (active) tab page.getTabPage
(int index) Gets the specified (by using its index) tab pageGets every tab page that is assigned to the tab component.int
Counts the tab pages that are added to the tab component.final TabType
Gets the tab type (position)next()
Selects the tab page, that is to the right of the currently selected (active) tab page.void
onHide()
The operations to be executed after the component is hidden on the clientvoid
onShow()
The operations to be executed after the component is displayed on the clientprevious()
Selects the tab page, that is to the left of the currently selected (active) tab page.removeTabPage
(int index) Removes the specified tab page from the component.removeTabPage
(TabPage tabPage) Removes a tab page from the tab componentfinal Tab
selectTab
(int index) Selects a tab page (makes it active).final Tab
Selects the specified tab page.final Tab
setTabType
(TabType tabType) Sets the type of the tab pages.boolean
writeHTML
(StringWriter writer) Creates the component's HTML equivalentMethods inherited from class com.jbstrap.ui.Component
_hide, _setAttribute, addAllowedRole, addComponent, addComponents, addDeniedRole, addHandler, addStyle, addStyleClass, addStyleClasses, afterDraw, clearfix, closeTag, combinateAccess, containsStyle, containsStyleClass, draw, drawSubComponents, error, flattendComponentTree, getAccess, getAccessMode, getAllowedRoles, getAttribute, getAttributes, getBackgroundColor, getBorderColor, getClient, getComponentById, getComponents, getComponents, getComponentsByClass, getData, getDeniedRoles, getHandlers, getId, getLanguageCode, getName, getParent, getParent, getRegisteredEvents, getStyle, getStyleClasses, getTextAlign, getTextColor, getToolTip, getToolTipPosition, getTypeName, getUI, init, insertComponentAfter, insertComponentBefore, isAccess, isDrawn, isEnabled, isEventBubbling, isVisible, onHotKeyEventHandler, openTag, redraw, removeAllComponents, removeAllowedRole, removeAllStyleClasses, removeAttribute, removeComponent, removeComponent, removeComponents, removeDeniedRole, removeHandler, removeStyle, removeStyle, removeStyleClass, removeStyleClasses, replaceComponent, replaceStyleClass, runAfterDraw, runJavaScript, runJavaScript, runJavaScript, runOnHide, runOnShow, say, setAttribute, setBackgroundColor, setBorder, setBorderColor, setData, setDisplayType, setEnabled, setEventBubbling, setFlex, setFloating, setHeight100, setHeight25, setHeight50, setHeight75, setHeightAuto, setLanguage, setMargin, setName, setOverflow, setPadding, setParent, setScrollable, setSelectionType, setShadow, setStyle, setTextAlign, setTextColor, setToolTip, setToolTipPosition, setVisible, setWidth100, setWidth25, setWidth50, setWidth75, setWidthAuto, showNotification, showNotification, showProcessIndicator, toggleStyleClass
Methods inherited from class com.jbstrap.core.messagebus.MessageBus
closeMessageBus, messageBusOpened, openMessageBus, renewSubscription, sendMessageToMessageBus, subscribeMessageBus, unsubscribeAllListeners, unsubscribeMessageBus
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.jbstrap.ui.Animatable
addAnimationEndHandler, addAnimationStartHandler, getAnimation, removeAnimation, setAnimation
Methods inherited from interface com.jbstrap.ui.CanDrop
addDropEventHandler
Methods inherited from interface com.jbstrap.ui.Draggable
addDragEndEventHandler, addDragStartEventHandler, setDraggable
-
Field Details
-
pages
-
-
Constructor Details
-
Tab
public Tab()Creates an empty, default tab component. -
Tab
Creates an empty, default tab component with the specified ID.- Parameters:
id
- The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)
-
Tab
Creates an empty tab component, with the specified tab type- Parameters:
type
- The tab position. For applicable values, see theTabType
enum. Ifnull
, the tab will use the default type.
-
Tab
Creates an empty tab component, with the specified tab type- Parameters:
id
- The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)type
- The tab position. For applicable values, see theTabType
enum. Ifnull
, the tab will use the default type.
-
Tab
Creates a tab component, in the default state, with the specified tab pages- Parameters:
tabPages
- The tab page component instances, that will be added to the tab. The pages will be added in the order they are specified.
-
Tab
Creates a tab component, in the default state, with the specified tab pages- Parameters:
id
- The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)tabPages
- The tab page component instances, that will be added to the tab. The pages will be added in the order they are specified.
-
Tab
Creates a tab component, with the specified tab type and tab pages.- Parameters:
tabType
- The tab position. For applicable values, see theTabType
enum. Ifnull
, the tab will use the default type.tabPages
- The tab page component instances, that will be added to the tab. The pages will be added in the order they are specified.
-
Tab
Creates a tab component, with the specified tab type and tab pages.- Parameters:
id
- The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)tabType
- The tab position. For applicable values, see theTabType
enum. Ifnull
, the tab will use the default type.tabPages
- The tab page component instances, that will be added to the tab. The pages will be added in the order they are specified.
-
-
Method Details
-
addTabPage
Adds the specified tab page to the tab component- Parameters:
tabPage
- The tab page component instance that will be added to the tab- Returns:
- The tab component
-
addTabPages
Adds multiple tab pages to the tab component- Parameters:
tabPages
- The tab page component instances, that will be added to the tab. The pages will be added in the order they are specified.- Returns:
- The tab component
-
addComponent
Adds a component to the tab component. The tab component can only have tab page component added to it.- Overrides:
addComponent
in classComponent<Tab>
- Parameters:
component
- The tab page component, that is to be added.- Returns:
- The tab component
- Throws:
IllegalArgumentException
- If the specified component is not aTabPage
, or extends from it.
-
onShow
public void onShow()Description copied from class:Component
The operations to be executed after the component is displayed on the clientBy default, this is an empty method. It has to be overwritten on a component or page, if additional operations have to be executed after the component is displayed. This method is nearly identical to the afterDraw() method, they differ in when they are executed. This method runs after the component is displayed on the client. Meaning that it is executed even if the component isn't redrawn, but only set to be visible after being hidden.
-
onHide
public void onHide()Description copied from class:Component
The operations to be executed after the component is hidden on the clientBy default, this is an empty method. It has to be overwritten on a component or page, if additional operations have to be executed after the component is hidden.
-
removeTabPage
Removes a tab page from the tab component- Parameters:
tabPage
- The tab page component instance that will be added to the tab- Returns:
- The tab component
-
removeTabPage
Removes the specified tab page from the component. The page can be specified by using its index. If the tab page is in an active state, then after it is removed, the first tab page will be active.- Parameters:
index
- The index of the tab page to be removed.- Returns:
- The tab component
-
selectTab
Selects a tab page (makes it active). The tab page can be specified by its index. An active tab page's contents are displayed on the interface.- Parameters:
index
- The index of the tab page to be selected (to be made active)- Returns:
- The tab component
-
selectTab
Selects the specified tab page. When a tab page is selected, it is active, and its contents will be displayed on the interface.- Parameters:
page
- The instance of the tab page to be selected.- Returns:
- The tab component
-
next
Selects the tab page, that is to the right of the currently selected (active) tab page. If the currently selected tab page is the last one, the method won't do anything.- Returns:
- The tab component
-
previous
Selects the tab page, that is to the left of the currently selected (active) tab page. If the currently selected tab page is the first one, the method won't do anything.- Returns:
- The tab component
-
getTabPage
Gets the specified (by using its index) tab page- Parameters:
index
- The index of the tab page- Returns:
- The tab page corresponding ot the specified index, or
null
, if the index doesn't correspond to a tab page.
-
setTabType
Sets the type of the tab pages.- Parameters:
tabType
- The tab position. For applicable values, see theTabType
enum. Ifnull
, the tab will use the default type.- Returns:
- The tab component
-
getTabType
Gets the tab type (position)- Returns:
- The tab type (position)
-
writeHTML
Description copied from class:Component
Creates the component's HTML equivalentThis method doesn't need to be used during application development. This method is used when developing a custom component. When creating a custom component, this method needs to be implemented. In the parameter (
StringWriter
class) the component's HTML equivalent must be specified, and the method has to return with a Boolean value. This boolean value determines if the component was drawn. If the user doesn't have access right to the component, or if the component couldn't be drawn, it should return withfalse
. Otherwise, it must return withtrue
. -
getCurrentTabPageIndex
Gets the index of the currently selected (active) tab page.- Returns:
- The index of the tab page, or
null
, if there isn't an active tab page.
-
getTabPages
Gets every tab page that is assigned to the tab component.- Returns:
- A list of the tab pages. If the tab component has nothing assigned to it, the list will be empty.
-
addTabClickHandler
Adds a tab page click handler (tab page change event). The specified event will be added to every tab page, so the event will be executed, regardless of which tab page the user clicks on.- Parameters:
handler
- TheClickEventHandler
implementation- See Also:
-
addTabClickHandler
Adds a tab page click handler (tab page change event) to the specified tab page. The specified handler will only run, if the user chooses the specified tab page.- Parameters:
tabIndex
- The index of the tab page, that will have the handler added to it.handler
- TheClickEventHandler
implementation- See Also:
-
getTabPagesCount
public int getTabPagesCount()Counts the tab pages that are added to the tab component.- Returns:
- The amount of the tab pages. If the tab component has none assigned to it, it will return with 0.
-
getCurrentTabPage
Gets the currently active tab page component.- Returns:
- The tab page component, that is currently active, or
null
, if there is no active tab page at the time of the query.
-