public class CloseableTabbedPane
extends javax.swing.JTabbedPane
It wraps the default tab component with a panel showing an additional close button.
Therefore the result of JTabbedPane.getTabComponentAt(int) differs from the component
added via setTabComponentAt(int, java.awt.Component).
javax.swing.JTabbedPane.AccessibleJTabbedPane, javax.swing.JTabbedPane.ModelListenerjavax.swing.JComponent.AccessibleJComponentchangeEvent, changeListener, model, SCROLL_TAB_LAYOUT, tabPlacement, WRAP_TAB_LAYOUTlistenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWaccessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT| Constructor and Description |
|---|
CloseableTabbedPane()
Creates an empty
TabbedPane with a default
tab placement of JTabbedPane.TOP. |
CloseableTabbedPane(int tabPlacement)
Creates an empty
TabbedPane with the specified tab placement
of either: JTabbedPane.TOP, JTabbedPane.BOTTOM,
JTabbedPane.LEFT, or JTabbedPane.RIGHT. |
CloseableTabbedPane(int tabPlacement,
int tabLayoutPolicy)
Creates an empty
TabbedPane with the specified tab placement
and tab layout policy. |
| Modifier and Type | Method and Description |
|---|---|
int |
indexOfTabComponent(java.awt.Component tabComponent)
Returns the index of the tab for the specified tab component.
|
void |
insertTab(java.lang.String title,
javax.swing.Icon icon,
java.awt.Component component,
java.lang.String tip,
int index)
Inserts a
component, at index,
represented by a title and/or icon,
either of which may be null. |
void |
setTabComponentAt(int index,
java.awt.Component component)
Sets the component that is responsible for rendering the
title for the specified tab.
|
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, isEnabledAt, paramString, remove, remove, removeAll, removeChangeListener, removeTabAt, setBackgroundAt, setComponentAt, setDisabledIconAt, setDisplayedMnemonicIndexAt, setEnabledAt, setForegroundAt, setIconAt, setMnemonicAt, setModel, setSelectedComponent, setSelectedIndex, setTabLayoutPolicy, setTabPlacement, setTitleAt, setToolTipTextAt, setUI, updateUIaddAncestorListener, 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, updateaddContainerListener, 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, validateTreeaction, 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, transferFocusUpCyclepublic CloseableTabbedPane()
TabbedPane with a default
tab placement of JTabbedPane.TOP.JTabbedPane.addTab(java.lang.String, javax.swing.Icon, java.awt.Component, java.lang.String)public CloseableTabbedPane(int tabPlacement)
TabbedPane with the specified tab placement
of either: JTabbedPane.TOP, JTabbedPane.BOTTOM,
JTabbedPane.LEFT, or JTabbedPane.RIGHT.tabPlacement - the placement for the tabs relative to the contentJTabbedPane.addTab(java.lang.String, javax.swing.Icon, java.awt.Component, java.lang.String)public CloseableTabbedPane(int tabPlacement,
int tabLayoutPolicy)
TabbedPane with the specified tab placement
and tab layout policy. Tab placement may be either:
JTabbedPane.TOP, JTabbedPane.BOTTOM,
JTabbedPane.LEFT, or JTabbedPane.RIGHT.
Tab layout policy may be either: JTabbedPane.WRAP_TAB_LAYOUT
or JTabbedPane.SCROLL_TAB_LAYOUT.tabPlacement - the placement for the tabs relative to the contenttabLayoutPolicy - the policy for laying out tabs when all tabs will not fit on one runjava.lang.IllegalArgumentException - if tab placement or tab layout policy are not
one of the above supported valuesJTabbedPane.addTab(java.lang.String, javax.swing.Icon, java.awt.Component, java.lang.String)public void insertTab(java.lang.String title,
javax.swing.Icon icon,
java.awt.Component component,
java.lang.String tip,
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.insertTab in class javax.swing.JTabbedPanetitle - 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.tip - the tooltip to be displayed for this tabindex - the position to insert this new tabJTabbedPane.addTab(java.lang.String, javax.swing.Icon, java.awt.Component, java.lang.String),
JTabbedPane.removeTabAt(int)public void setTabComponentAt(int index,
java.awt.Component component)
JTabbedPane will render the title and/or icon for
the specified tab. A non-null value means the component will
render the title and JTabbedPane will not render
the title and/or icon.
Note: The component must not be one that the developer has already added to the tabbed pane.
Attention: Because of the internal implementation which adds the
close button the component returned by JTabbedPane.getTabComponentAt(int)
is not the one added here, but its first child.
setTabComponentAt in class javax.swing.JTabbedPaneindex - the tab index where the component should be setcomponent - the component to render the title for the
specified tabjava.lang.IndexOutOfBoundsException - if index is out of range
(index < 0 || index >= tab count)java.lang.IllegalArgumentException - if component has already been
added to this JTabbedPaneJTabbedPane.getTabComponentAt(int)public int indexOfTabComponent(java.awt.Component tabComponent)
indexOfTabComponent in class javax.swing.JTabbedPanetabComponent - the tab component for the tabsetTabComponentAt(int, java.awt.Component),
JTabbedPane.getTabComponentAt(int)