Class FlatTabbedPane
- All Implemented Interfaces:
FlatComponentExtension
,FlatStyleableComponent
,ImageObserver
,MenuContainer
,Serializable
,Accessible
,SwingConstants
JTabbedPane
that provides easy access to FlatLaf specific client properties.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
static enum
static enum
static enum
static enum
static enum
static enum
static enum
Nested classes/interfaces inherited from class javax.swing.JTabbedPane
JTabbedPane.AccessibleJTabbedPane, JTabbedPane.ModelListener
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
Fields inherited from class javax.swing.JTabbedPane
changeEvent, changeListener, model, SCROLL_TAB_LAYOUT, tabPlacement, WRAP_TAB_LAYOUT
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns a component that will be placed at the leading edge of the tabs area.int
Returns the maximum width of a tab.int
getMaximumTabWidth
(int tabIndex) Returns the maximum width of the tab at the given tab index.int
Returns the minimum width of a tab.int
getMinimumTabWidth
(int tabIndex) Returns the minimum width of the tab at the given tab index.Returns the placement of the forward/backward scroll arrow buttons.Returns the display policy for the forward/backward scroll arrow buttons.Returns the horizontal alignment of the tab title and icon.Returns the alignment of the tab area.Returns the insets of the tab area.Returns the callback that is invoked when a tab close button is clicked.getTabCloseCallback
(int tabIndex) Returns the callback that is invoked when the tab close button at the given tab index is clicked.Returns the tooltip text used for tab close buttons.getTabCloseToolTipText
(int tabIndex) Returns the tooltip text used for tab close button at the given tab index.int
Returns the minimum height of a tab.int
Returns the tab icon placement (relative to tab title).Returns the insets of a tab.getTabInsets
(int tabIndex) Returns the insets of the tab at the given tab index.Returns how the tabs should be rotated.Returns the display policy for the "more tabs" button, which shows a popup menu with the (partly) hidden tabs.Returns type of selected tab.Returns how the tabs should be sized.Returns a component that will be placed at the trailing edge of the tabs area.boolean
Returns whether a full border is painted around a tabbed pane.boolean
Returns whether the tab area should be hidden if it contains only one tab.boolean
Returns whether the separator between tabs area and content area should be shown.boolean
Returns whether separators are shown between tabs.isTabClosable
(int tabIndex) Returns whether the tab at the given tab index is closable.boolean
Returns whether all tabs are closable.void
setHasFullBorder
(boolean hasFullBorder) Specifies whether a full border is painted around a tabbed pane.void
setHideTabAreaWithOneTab
(boolean hideTabAreaWithOneTab) Specifies whether the tab area should be hidden if it contains only one tab.void
setLeadingComponent
(Component leadingComponent) Specifies a component that will be placed at the leading edge of the tabs area.void
setMaximumTabWidth
(int maximumTabWidth) Specifies the maximum width of a tab.void
setMaximumTabWidth
(int tabIndex, int maximumTabWidth) Specifies the maximum width of the tab at the given tab index.void
setMinimumTabWidth
(int minimumTabWidth) Specifies the minimum width of a tab.void
setMinimumTabWidth
(int tabIndex, int minimumTabWidth) Specifies the minimum width of the tab at the given tab index.void
setScrollButtonsPlacement
(FlatTabbedPane.ScrollButtonsPlacement scrollButtonsPlacement) Specifies the placement of the forward/backward scroll arrow buttons.void
setScrollButtonsPolicy
(FlatTabbedPane.ScrollButtonsPolicy scrollButtonsPolicy) Specifies the display policy for the forward/backward scroll arrow buttons.void
setShowContentSeparators
(boolean showContentSeparators) Specifies whether the separator between tabs area and content area should be shown.void
setShowTabSeparators
(boolean showTabSeparators) Specifies whether separators are shown between tabs.void
setTabAlignment
(FlatTabbedPane.TabAlignment tabAlignment) Specifies the horizontal alignment of the tab title and icon.void
setTabAreaAlignment
(FlatTabbedPane.TabAreaAlignment tabAreaAlignment) Specifies the alignment of the tab area.void
setTabAreaInsets
(Insets tabAreaInsets) Specifies the insets of the tab area.void
setTabClosable
(int tabIndex, boolean tabClosable) Specifies whether the tab at the given tab index is closable.void
setTabCloseCallback
(int tabIndex, BiConsumer<JTabbedPane, Integer> tabCloseCallback) Specifies the callback that is invoked when the tab close button at the given tab index is clicked.void
setTabCloseCallback
(BiConsumer<JTabbedPane, Integer> tabCloseCallback) Specifies the callback that is invoked when a tab close button is clicked.void
setTabCloseToolTipText
(int tabIndex, String tabCloseToolTipText) Specifies the tooltip text used for tab close button at the given tab index.void
setTabCloseToolTipText
(String tabCloseToolTipText) Specifies the tooltip text used for tab close buttons.void
setTabHeight
(int tabHeight) Specifies the minimum height of a tab.void
setTabIconPlacement
(int tabIconPlacement) Specifies the tab icon placement (relative to tab title).void
setTabInsets
(int tabIndex, Insets tabInsets) Specifies the insets of the tab at the given tab index.void
setTabInsets
(Insets tabInsets) Specifies the insets of a tab.void
setTabRotation
(FlatTabbedPane.TabRotation tabRotation) Specifies how the tabs should be rotated.void
setTabsClosable
(boolean tabClosable) Specifies whether all tabs are closable.void
setTabsPopupPolicy
(FlatTabbedPane.TabsPopupPolicy tabsPopupPolicy) Specifies the display policy for the "more tabs" button, which shows a popup menu with the (partly) hidden tabs.void
setTabType
(FlatTabbedPane.TabType tabType) Specifies type of selected tab.void
setTabWidthMode
(FlatTabbedPane.TabWidthMode tabWidthMode) Specifies how the tabs should be sized.void
setTrailingComponent
(Component trailingComponent) Specifies a component that will be placed at the trailing edge of the tabs area.Methods inherited from class javax.swing.JTabbedPane
add, add, add, add, add, addChangeListener, addTab, addTab, addTab, createChangeListener, fireStateChanged, getAccessibleContext, getBackgroundAt, getBoundsAt, getChangeListeners, getComponentAt, getDisabledIconAt, getDisplayedMnemonicIndexAt, getForegroundAt, getIconAt, getMnemonicAt, getModel, getSelectedComponent, getSelectedIndex, getTabComponentAt, getTabCount, getTabLayoutPolicy, getTabPlacement, getTabRunCount, getTitleAt, getToolTipText, getToolTipTextAt, getUI, getUIClassID, indexAtLocation, indexOfComponent, indexOfTab, indexOfTab, indexOfTabComponent, insertTab, isEnabledAt, paramString, remove, remove, removeAll, removeChangeListener, removeTabAt, setBackgroundAt, setComponentAt, setDisabledIconAt, setDisplayedMnemonicIndexAt, setEnabledAt, setForegroundAt, setIconAt, setMnemonicAt, setModel, setSelectedComponent, setSelectedIndex, setTabComponentAt, setTabLayoutPolicy, setTabPlacement, setTitleAt, setToolTipTextAt, setUI, updateUI
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, 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, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, 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
Methods inherited from class java.awt.Container
addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, 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, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
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, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.formdev.flatlaf.extras.components.FlatComponentExtension
getClientProperty, getClientPropertyBoolean, getClientPropertyBoolean, getClientPropertyColor, getClientPropertyEnumString, getClientPropertyInsets, getClientPropertyInt, getClientPropertyInt, putClientProperty, putClientPropertyBoolean, putClientPropertyEnumString
Methods inherited from interface com.formdev.flatlaf.extras.components.FlatStyleableComponent
getClientProperty, getStyle, getStyleClass, getStyleMap, putClientProperty, setStyle, setStyleClass, setStyleMap
-
Constructor Details
-
FlatTabbedPane
public FlatTabbedPane()
-
-
Method Details
-
isShowTabSeparators
public boolean isShowTabSeparators()Returns whether separators are shown between tabs. -
setShowTabSeparators
public void setShowTabSeparators(boolean showTabSeparators) Specifies whether separators are shown between tabs. -
isShowContentSeparators
public boolean isShowContentSeparators()Returns whether the separator between tabs area and content area should be shown. -
setShowContentSeparators
public void setShowContentSeparators(boolean showContentSeparators) Specifies whether the separator between tabs area and content area should be shown. -
isHasFullBorder
public boolean isHasFullBorder()Returns whether a full border is painted around a tabbed pane. -
setHasFullBorder
public void setHasFullBorder(boolean hasFullBorder) Specifies whether a full border is painted around a tabbed pane. -
isHideTabAreaWithOneTab
public boolean isHideTabAreaWithOneTab()Returns whether the tab area should be hidden if it contains only one tab. -
setHideTabAreaWithOneTab
public void setHideTabAreaWithOneTab(boolean hideTabAreaWithOneTab) Specifies whether the tab area should be hidden if it contains only one tab. -
getMinimumTabWidth
public int getMinimumTabWidth()Returns the minimum width of a tab. -
setMinimumTabWidth
public void setMinimumTabWidth(int minimumTabWidth) Specifies the minimum width of a tab. -
getMinimumTabWidth
public int getMinimumTabWidth(int tabIndex) Returns the minimum width of the tab at the given tab index. -
setMinimumTabWidth
public void setMinimumTabWidth(int tabIndex, int minimumTabWidth) Specifies the minimum width of the tab at the given tab index. -
getMaximumTabWidth
public int getMaximumTabWidth()Returns the maximum width of a tab. -
setMaximumTabWidth
public void setMaximumTabWidth(int maximumTabWidth) Specifies the maximum width of a tab.Applied only if tab does not have a custom tab component (see
JTabbedPane.setTabComponentAt(int, java.awt.Component)
). -
getMaximumTabWidth
public int getMaximumTabWidth(int tabIndex) Returns the maximum width of the tab at the given tab index. -
setMaximumTabWidth
public void setMaximumTabWidth(int tabIndex, int maximumTabWidth) Specifies the maximum width of the tab at the given tab index.Applied only if tab does not have a custom tab component (see
JTabbedPane.setTabComponentAt(int, java.awt.Component)
). -
getTabHeight
public int getTabHeight()Returns the minimum height of a tab. -
setTabHeight
public void setTabHeight(int tabHeight) Specifies the minimum height of a tab.- See Also:
-
getTabInsets
Returns the insets of a tab. -
setTabInsets
Specifies the insets of a tab.- See Also:
-
getTabInsets
Returns the insets of the tab at the given tab index. -
setTabInsets
Specifies the insets of the tab at the given tab index.- See Also:
-
getTabAreaInsets
Returns the insets of the tab area. -
setTabAreaInsets
Specifies the insets of the tab area. -
isTabsClosable
public boolean isTabsClosable()Returns whether all tabs are closable. -
setTabsClosable
public void setTabsClosable(boolean tabClosable) Specifies whether all tabs are closable. If set totrue
, all tabs in that tabbed pane are closable. To make individual tabs closable, usesetTabClosable(int, boolean)
.Note that you have to specify a callback (see
setTabCloseCallback(BiConsumer)
) that is invoked when the user clicks a tab close button. The callback is responsible for closing the tab. -
isTabClosable
Returns whether the tab at the given tab index is closable. -
setTabClosable
public void setTabClosable(int tabIndex, boolean tabClosable) Specifies whether the tab at the given tab index is closable. To make all tabs closable, usesetTabsClosable(boolean)
.Note that you have to specify a callback (see
setTabCloseCallback(BiConsumer)
) that is invoked when the user clicks a tab close button. The callback is responsible for closing the tab. -
getTabCloseToolTipText
Returns the tooltip text used for tab close buttons. -
setTabCloseToolTipText
Specifies the tooltip text used for tab close buttons. -
getTabCloseToolTipText
Returns the tooltip text used for tab close button at the given tab index. -
setTabCloseToolTipText
Specifies the tooltip text used for tab close button at the given tab index. -
getTabCloseCallback
Returns the callback that is invoked when a tab close button is clicked. The callback is responsible for closing the tab. -
setTabCloseCallback
Specifies the callback that is invoked when a tab close button is clicked. The callback is responsible for closing the tab.Use a
BiConsumer
<javax.swing.JTabbedPane, Integer> that receives the tabbed pane and the tab index as parameters:
If you need to check whether a modifier key (e.g. Alt or Shift) was pressed while the user clicked the tab close button, usemyTabbedPane.setTabCloseCallback( (tabbedPane, tabIndex) -> { // close tab here } );
EventQueue.getCurrentEvent()
to get current event, check whether it is aMouseEvent
and invoke its methods. E.g.AWTEvent e = EventQueue.getCurrentEvent(); boolean shift = (e instanceof MouseEvent) ? ((MouseEvent)e).isShiftDown() : false;
-
getTabCloseCallback
Returns the callback that is invoked when the tab close button at the given tab index is clicked. The callback is responsible for closing the tab. -
setTabCloseCallback
Specifies the callback that is invoked when the tab close button at the given tab index is clicked. The callback is responsible for closing the tab.- See Also:
-
getTabType
Returns type of selected tab.- Since:
- 2
-
setTabType
Specifies type of selected tab.- Since:
- 2
-
getTabsPopupPolicy
Returns the display policy for the "more tabs" button, which shows a popup menu with the (partly) hidden tabs. -
setTabsPopupPolicy
Specifies the display policy for the "more tabs" button, which shows a popup menu with the (partly) hidden tabs. -
getScrollButtonsPolicy
Returns the display policy for the forward/backward scroll arrow buttons. -
setScrollButtonsPolicy
Specifies the display policy for the forward/backward scroll arrow buttons. -
getScrollButtonsPlacement
Returns the placement of the forward/backward scroll arrow buttons. -
setScrollButtonsPlacement
Specifies the placement of the forward/backward scroll arrow buttons. -
getTabAreaAlignment
Returns the alignment of the tab area. -
setTabAreaAlignment
Specifies the alignment of the tab area. -
getTabAlignment
Returns the horizontal alignment of the tab title and icon. -
setTabAlignment
Specifies the horizontal alignment of the tab title and icon. -
getTabWidthMode
Returns how the tabs should be sized. -
setTabWidthMode
Specifies how the tabs should be sized. -
getTabRotation
Returns how the tabs should be rotated.- Since:
- 3.3
-
setTabRotation
Specifies how the tabs should be rotated.- Since:
- 3.3
-
getTabIconPlacement
public int getTabIconPlacement()Returns the tab icon placement (relative to tab title). -
setTabIconPlacement
public void setTabIconPlacement(int tabIconPlacement) Specifies the tab icon placement (relative to tab title).Allowed Values are:
-
getLeadingComponent
Returns a component that will be placed at the leading edge of the tabs area. -
setLeadingComponent
Specifies a component that will be placed at the leading edge of the tabs area.For top and bottom tab placement, the layed out component size will be the preferred component width and the tab area height.
For left and right tab placement, the layed out component size will be the tab area width and the preferred component height. -
getTrailingComponent
Returns a component that will be placed at the trailing edge of the tabs area. -
setTrailingComponent
Specifies a component that will be placed at the trailing edge of the tabs area.For top and bottom tab placement, the layed out component size will be the available horizontal space (minimum is preferred component width) and the tab area height.
For left and right tab placement, the layed out component size will be the tab area width and the available vertical space (minimum is preferred component height).
-