public final class ScrollableTabBar
extends javax.swing.JComponent
CustomTab
) with buttons that can be used to scroll between the
tabs and access a drop down menu containing a list of all tabs.
The way in which scrolling works in the bar may be controlled using the
scrollMode
property. The component
can support a scrolling mode which switches between tabs when the user
clicks the left and right buttons, or a mode where the area containing the
tabs is paged much like a scrollable view port.
You can programmatically display the drop down menu containing the list
of tabs using the showDropDownMenu()
method.
You can install a custom component
into the tab bar. The custom component will be positioned between the tabs
and the tab switching controls, and will take any remaining horizontal
space available. This area is used by many consumers of this class to
host a horizontal scrollbar for the component(s) being controlled by the
tabs.
You can control whether or not the tab area will disappear when only one
tab is visible using the setHideSingleTab(boolean)
method. By
default, the tab area is always visible.
Modifier and Type | Class and Description |
---|---|
static class |
ScrollableTabBar.ScrollMode
The behavior of the scroll left / right buttons.
|
javax.swing.JComponent.AccessibleJComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Constructor and Description |
---|
ScrollableTabBar()
Constructs a ScrollableTabBar.
|
ScrollableTabBar(int position)
Constructs a ScrollableTabBar.
|
Modifier and Type | Method and Description |
---|---|
void |
doLayout() |
void |
ensureSelectedTabVisible()
Ensures that the selected tab is visible.
|
java.awt.Component |
getCustomComponent()
Gets the custom component.
|
boolean |
getHideSingleTab()
Gets whether the tab area is hidden if there is only a single tab.
|
java.awt.Dimension |
getPreferredSize() |
ScrollableTabBar.ScrollMode |
getScrollMode()
Gets the behavior of the left and right scroll buttons.
|
CustomTab |
getTabs()
Gets the tabs.
|
protected void |
paintComponent(java.awt.Graphics g) |
void |
removeScrollButtons()
Removes the scroll buttons
|
void |
setCustomComponent(java.awt.Component customComponent)
Sets the custom component to install between the tabs and the scroll
buttons.
|
void |
setHideButtonsWhenAllTabsVisible(boolean hideButtons)
Sets whether the left/right navigation buttons should be visible
when all tabs can be displayed.
|
void |
setHideSingleTab(boolean hideSingleTab)
Sets whether the tab area is hidden if there is only a single tab.
|
void |
setScrollMode(ScrollableTabBar.ScrollMode mode)
Controls the behavior of the left and right scroll buttons.
|
void |
showDropDownMenu()
Programmatically makes the drop down menu containing the list of tabs
visible.
|
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public ScrollableTabBar()
public ScrollableTabBar(int position)
position
- SwingConstants.TOP or SwingConstants.BOTTOMpublic void removeScrollButtons()
public void setHideSingleTab(boolean hideSingleTab)
This property is false by default.
hideSingleTab
- if true, the tab bar is hidden if only
one tab exists.public void setHideButtonsWhenAllTabsVisible(boolean hideButtons)
hideButtons
- true if left/right navigation buttons should be displayed;
false otherwisepublic boolean getHideSingleTab()
public void setCustomComponent(java.awt.Component customComponent)
customComponent
- a custom component to install. You may pass
null into this method, which removes any existing
custom component.public java.awt.Component getCustomComponent()
public CustomTab getTabs()
public void setScrollMode(ScrollableTabBar.ScrollMode mode)
mode
- the scroll mode.ScrollableTabBar.ScrollMode
public ScrollableTabBar.ScrollMode getScrollMode()
public void showDropDownMenu()
public void ensureSelectedTabVisible()
public void doLayout()
doLayout
in class java.awt.Container
public java.awt.Dimension getPreferredSize()
getPreferredSize
in class javax.swing.JComponent
protected void paintComponent(java.awt.Graphics g)
paintComponent
in class javax.swing.JComponent