Package adams.gui.core
Class BaseTabbedPane
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JTabbedPane
-
- adams.gui.core.BaseTabbedPane
-
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
,Accessible
,SwingConstants
- Direct Known Subclasses:
BaseTabbedPaneWithTabHiding
,DragAndDropTabbedPane
public class BaseTabbedPane extends JTabbedPane
Enhanced JTabbedPane. Offers closing of tabs with middle mouse button.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
BaseTabbedPane.MiddleMouseButtonCloseApprover
Interface for classes that can hook into the closing using the middle mouse button and stop it.static class
BaseTabbedPane.TabUndo
Container for the tab undo list.static class
BaseTabbedPane.TabUndoList
For storing the tab undo containers.-
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 Modifier and Type Field Description protected boolean
m_CloseTabsWithMiddleMouseButton
Allows the user to close tabs with the middle mouse button.protected boolean
m_DetachableTabs
whether to make tabs detachable.protected int
m_MaxTabCloseUndo
the maximum number of tabs to keep for undo.protected int
m_MaxTitleLength
the maximum length in chars for titles before getting shortened.protected BaseTabbedPane.MiddleMouseButtonCloseApprover
m_MiddleMouseButtonCloseApprover
the approver for the middle mouse button.protected boolean
m_PromptUserWhenClosingTab
whether to prompt user when closing a tab.protected boolean
m_ShowCloseTabButton
whether to show a "close tab" button.protected boolean
m_SkipTabUndo
whether to skip tab undo.protected Set<ChangeListener>
m_TabChangeListeners
the listeners for tab changes.protected Set<TabClosedListener>
m_TabClosedListeners
the listeners for tabs being closed.protected BaseTabbedPane.TabUndoList
m_TabUndoList
the list of tabs to undo.-
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 Constructor Description BaseTabbedPane()
Creates an emptyTabbedPane
with a default tab placement ofJTabbedPane.TOP
.BaseTabbedPane(int tabPlacement)
Creates an emptyTabbedPane
with the specified tab placement of either:JTabbedPane.TOP
,JTabbedPane.BOTTOM
,JTabbedPane.LEFT
, orJTabbedPane.RIGHT
.BaseTabbedPane(int tabPlacement, int tabLayoutPolicy)
Creates an emptyTabbedPane
with the specified tab placement and tab layout policy.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addTabChangeListener(ChangeListener l)
Adds the listener for changes in tabs.void
addTabClosedListeners(TabClosedListener l)
Adds the listener for closing tabs.protected void
addTabUndo(int index)
Adds the tab to its undo list, if enabled.protected void
afterTabClosedWithMiddleMouseButton(int index, Component comp)
Hook method that gets executed after a tab was successfully removed with a middle mouse button click.boolean
canCloseTab(int index)
Prompts the user whether the tab can be closed.protected boolean
canCloseTabWithMiddleMouseButton(int index)
Hook method that checks whether the specified tab can really be closed with a click of the middle mouse button.protected boolean
canMoveTabTo(int from, int to)
Returns whether the tab can be moved.boolean
canMoveTabToEnd(int from)
Returns whether the tab can be moved to the end.boolean
canMoveTabToLeft(int from)
Returns whether the tab can be moved to the left.boolean
canMoveTabToRight(int from)
Returns whether the tab can be moved to the right.boolean
canMoveTabToStart(int from)
Returns whether the tab can be moved to the start.boolean
canUndoTabClose()
Returns whether a tab close can be undone.void
clearTabChangeListeners()
Removes all tab change listeners.void
clearTabClosedListeners()
Removes all tab closed listeners.protected void
finishInit()
Finishes the initialization.protected BaseTabbedPane.TabUndo
generateTabUndo(int index)
Generates a tab undo container.boolean
getCloseTabsWithMiddelMouseButton()
Returns whether users can close tabs with the middle mouse button.boolean
getDetachableTabs()
Returns whether to allow tabs to be detached.int
getMaxTabCloseUndo()
Returns the maximum tabs to keep around for undoing closing.int
getMaxTitleLength()
Returns the maximum title length to allow before shortening when usingsetShortenedTitleAt(int, String)
.BaseTabbedPane.MiddleMouseButtonCloseApprover
getMiddleMouseButtonCloseApprover()
Returns the approver for the middle mouse button.boolean
getPromptUserWhenClosingTab()
Returns whether to prompt the user when closing a tab.boolean
getShowCloseTabButton()
Returns whether to show "close tab" buttons.BaseMenu
getTabMoveSubMenu(int index)
Generates the submenu for moving tabs.protected BaseTabbedPane.TabUndoList
getTabUndoList()
Returns the tab undo list.protected void
initGUI()
Performs further initializations of widgets.protected void
initialize()
Performs further initializations of widgets.void
insertTab(String title, Icon icon, Component component, String tip, int index)
Inserts a new tab for the given component, at the given index, represented by the given title and/or icon, either of which may benull
.protected void
moveTabTo(int from, int to)
Moves a tab from A to B.boolean
moveTabToEnd(int index)
Moves the tab to the right most position.boolean
moveTabToLeft(int index)
Moves the tab to the left.boolean
moveTabToRight(int index)
Moves the tab to the right.boolean
moveTabToStart(int index)
Moves the tab to the left most position.protected void
notifyTabChangeListeners()
Notifies all the tab change listenersprotected void
notifyTabClosedListeners(int tabIndex, Component component)
Notifies all the tab closed listenersvoid
removeAll()
Removes all the tabs and their corresponding components from thetabbedpane
.boolean
removeSelectedTab()
Removes the currently selected tab.void
removeTabAt(int index)
Removes the tab atindex
.void
removeTabChangeListener(ChangeListener l)
Removes the listener for changes in tabs.void
removeTabClosedListeners(TabClosedListener l)
Removes the listener for closing tabs.void
setCloseTabsWithMiddleMouseButton(boolean value)
Sets whether users can close tabs with the middle mouse button.void
setDetachableTabs(boolean value)
Sets whether to allow tabs to be detached.void
setMaxTabCloseUndo(int value)
Sets the maximum tabs to keep around for undoing closing.void
setMaxTitleLength(int value)
Sets the maximum title length to allow before shortening when usingsetShortenedTitleAt(int, String)
.void
setMiddleMouseButtonCloseApprover(BaseTabbedPane.MiddleMouseButtonCloseApprover value)
Sets the approver for the middle mouse button.void
setPromptUserWhenClosingTab(boolean value)
Sets whether to prompt the user when closing a tab.void
setShortenedTitleAt(int index, String title)
Sets the title for the tab at the specified position.void
setShowCloseTabButton(boolean value)
Sets whether to show "close tab" buttons.void
setTitleAt(int index, String title)
Sets the title for the tab at the specified position.protected void
tabClicked(MouseEvent e)
Gets called when the user clicks on a tab.boolean
undoTabClose()
Performs an undo of a tab close.protected void
updateTabComponents()
Updates the tab components.-
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, isEnabledAt, paramString, remove, remove, removeChangeListener, setBackgroundAt, setComponentAt, setDisabledIconAt, setDisplayedMnemonicIndexAt, setEnabledAt, setForegroundAt, setIconAt, setMnemonicAt, setModel, setSelectedComponent, setSelectedIndex, setTabComponentAt, setTabLayoutPolicy, setTabPlacement, 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
-
-
-
-
Field Detail
-
m_CloseTabsWithMiddleMouseButton
protected boolean m_CloseTabsWithMiddleMouseButton
Allows the user to close tabs with the middle mouse button.
-
m_MiddleMouseButtonCloseApprover
protected BaseTabbedPane.MiddleMouseButtonCloseApprover m_MiddleMouseButtonCloseApprover
the approver for the middle mouse button.
-
m_ShowCloseTabButton
protected boolean m_ShowCloseTabButton
whether to show a "close tab" button.
-
m_PromptUserWhenClosingTab
protected boolean m_PromptUserWhenClosingTab
whether to prompt user when closing a tab.
-
m_DetachableTabs
protected boolean m_DetachableTabs
whether to make tabs detachable.
-
m_MaxTitleLength
protected int m_MaxTitleLength
the maximum length in chars for titles before getting shortened.
-
m_MaxTabCloseUndo
protected int m_MaxTabCloseUndo
the maximum number of tabs to keep for undo.
-
m_TabUndoList
protected transient BaseTabbedPane.TabUndoList m_TabUndoList
the list of tabs to undo.
-
m_SkipTabUndo
protected boolean m_SkipTabUndo
whether to skip tab undo.
-
m_TabChangeListeners
protected Set<ChangeListener> m_TabChangeListeners
the listeners for tab changes.
-
m_TabClosedListeners
protected Set<TabClosedListener> m_TabClosedListeners
the listeners for tabs being closed.
-
-
Constructor Detail
-
BaseTabbedPane
public BaseTabbedPane()
Creates an emptyTabbedPane
with a default tab placement ofJTabbedPane.TOP
.
-
BaseTabbedPane
public BaseTabbedPane(int tabPlacement)
Creates an emptyTabbedPane
with the specified tab placement of either:JTabbedPane.TOP
,JTabbedPane.BOTTOM
,JTabbedPane.LEFT
, orJTabbedPane.RIGHT
.- Parameters:
tabPlacement
- the placement for the tabs relative to the content
-
BaseTabbedPane
public BaseTabbedPane(int tabPlacement, int tabLayoutPolicy)
Creates an emptyTabbedPane
with the specified tab placement and tab layout policy. Tab placement may be either:JTabbedPane.TOP
,JTabbedPane.BOTTOM
,JTabbedPane.LEFT
, orJTabbedPane.RIGHT
. Tab layout policy may be either:JTabbedPane.WRAP_TAB_LAYOUT
orJTabbedPane.SCROLL_TAB_LAYOUT
.- Parameters:
tabPlacement
- the placement for the tabs relative to the contenttabLayoutPolicy
- the policy for laying out tabs when all tabs will not fit on one run
-
-
Method Detail
-
initialize
protected void initialize()
Performs further initializations of widgets.
-
initGUI
protected void initGUI()
Performs further initializations of widgets.
-
finishInit
protected void finishInit()
Finishes the initialization.
-
tabClicked
protected void tabClicked(MouseEvent e)
Gets called when the user clicks on a tab.
Default implementation closes tabs if automatic closing of tabs is enabled.
-
canCloseTab
public boolean canCloseTab(int index)
Prompts the user whether the tab can be closed.- Parameters:
index
- the index of the tab to be closed- Returns:
- true if can be closed
-
canCloseTabWithMiddleMouseButton
protected boolean canCloseTabWithMiddleMouseButton(int index)
Hook method that checks whether the specified tab can really be closed with a click of the middle mouse button.
Default implementation always returns true.- Parameters:
index
- the tab index- Returns:
- true if tab can be closed
- See Also:
getCloseTabsWithMiddelMouseButton()
-
afterTabClosedWithMiddleMouseButton
protected void afterTabClosedWithMiddleMouseButton(int index, Component comp)
Hook method that gets executed after a tab was successfully removed with a middle mouse button click.
Default implementation calls cleanUp() method ofCleanUpHandler
instances.- Parameters:
index
- the original indexcomp
- the component that was removed
-
setCloseTabsWithMiddleMouseButton
public void setCloseTabsWithMiddleMouseButton(boolean value)
Sets whether users can close tabs with the middle mouse button.- Parameters:
value
- if true then users can close tabs with the middle mouse button- See Also:
canCloseTabWithMiddleMouseButton(int)
-
getCloseTabsWithMiddelMouseButton
public boolean getCloseTabsWithMiddelMouseButton()
Returns whether users can close tabs with the middle mouse button.- Returns:
- true if users can close tabs with the middle mouse button
- See Also:
canCloseTabWithMiddleMouseButton(int)
-
setMiddleMouseButtonCloseApprover
public void setMiddleMouseButtonCloseApprover(BaseTabbedPane.MiddleMouseButtonCloseApprover value)
Sets the approver for the middle mouse button.- Parameters:
value
- the approver
-
getMiddleMouseButtonCloseApprover
public BaseTabbedPane.MiddleMouseButtonCloseApprover getMiddleMouseButtonCloseApprover()
Returns the approver for the middle mouse button.- Returns:
- the approver, null if none set
-
setShowCloseTabButton
public void setShowCloseTabButton(boolean value)
Sets whether to show "close tab" buttons.- Parameters:
value
- true if to show buttons
-
getShowCloseTabButton
public boolean getShowCloseTabButton()
Returns whether to show "close tab" buttons.- Returns:
- true if button displayed
-
setDetachableTabs
public void setDetachableTabs(boolean value)
Sets whether to allow tabs to be detached.- Parameters:
value
- true if detachable
-
getDetachableTabs
public boolean getDetachableTabs()
Returns whether to allow tabs to be detached.- Returns:
- true if detachable
-
updateTabComponents
protected void updateTabComponents()
Updates the tab components.
-
setPromptUserWhenClosingTab
public void setPromptUserWhenClosingTab(boolean value)
Sets whether to prompt the user when closing a tab.- Parameters:
value
- true if to prompt
-
getPromptUserWhenClosingTab
public boolean getPromptUserWhenClosingTab()
Returns whether to prompt the user when closing a tab.- Returns:
- true if to prompt
-
removeSelectedTab
public boolean removeSelectedTab()
Removes the currently selected tab.- Returns:
- true if a tab was removed
-
insertTab
public void insertTab(String title, Icon icon, Component component, String tip, int index)
Inserts a new tab for the given component, at the given index, represented by the given title and/or icon, either of which may benull
.- Overrides:
insertTab
in classJTabbedPane
- Parameters:
title
- the title to be displayed on the tabicon
- the icon to be displayed on the 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 tab (> 0 and <= getTabCount()
)- Throws:
IndexOutOfBoundsException
- if the index is out of range (< 0 or > getTabCount()
)
-
setTitleAt
public void setTitleAt(int index, String title)
Sets the title for the tab at the specified position.- Overrides:
setTitleAt
in classJTabbedPane
- Parameters:
index
- the position of the tabtitle
- the new title
-
setShortenedTitleAt
public void setShortenedTitleAt(int index, String title)
Sets the title for the tab at the specified position.- Parameters:
index
- the position of the tabtitle
- the new title
-
setMaxTitleLength
public void setMaxTitleLength(int value)
Sets the maximum title length to allow before shortening when usingsetShortenedTitleAt(int, String)
.- Parameters:
value
- the maximum length in chars
-
getMaxTitleLength
public int getMaxTitleLength()
Returns the maximum title length to allow before shortening when usingsetShortenedTitleAt(int, String)
.- Returns:
- the maximum length in chars
-
setMaxTabCloseUndo
public void setMaxTabCloseUndo(int value)
Sets the maximum tabs to keep around for undoing closing.- Parameters:
value
- the maximum, <1 turned off
-
getMaxTabCloseUndo
public int getMaxTabCloseUndo()
Returns the maximum tabs to keep around for undoing closing.- Returns:
- the maximum, <1 turned off
-
getTabUndoList
protected BaseTabbedPane.TabUndoList getTabUndoList()
Returns the tab undo list.- Returns:
- the list
-
generateTabUndo
protected BaseTabbedPane.TabUndo generateTabUndo(int index)
Generates a tab undo container.- Parameters:
index
- the index of the tab to back up- Returns:
- the undo container
-
addTabUndo
protected void addTabUndo(int index)
Adds the tab to its undo list, if enabled.- Parameters:
index
- the position of the tab
-
canUndoTabClose
public boolean canUndoTabClose()
Returns whether a tab close can be undone.- Returns:
- true if possible
-
undoTabClose
public boolean undoTabClose()
Performs an undo of a tab close.- Returns:
- true if successfully restored
-
removeTabAt
public void removeTabAt(int index)
Removes the tab atindex
. Automatically handles the tab undo.- Overrides:
removeTabAt
in classJTabbedPane
- Parameters:
index
- the index of the tab to be removed- Throws:
IndexOutOfBoundsException
- if index is out of range(index < 0 || index >= tab count)
-
removeAll
public void removeAll()
Removes all the tabs and their corresponding components from thetabbedpane
. Bypasses undo for tabs, clears the undo list.- Overrides:
removeAll
in classJTabbedPane
-
canMoveTabTo
protected boolean canMoveTabTo(int from, int to)
Returns whether the tab can be moved.- Parameters:
from
- the current tab's indexto
- the destination index- Returns:
- true if can be moved
-
canMoveTabToStart
public boolean canMoveTabToStart(int from)
Returns whether the tab can be moved to the start.- Parameters:
from
- the current tab's index- Returns:
- true if can be moved
-
canMoveTabToLeft
public boolean canMoveTabToLeft(int from)
Returns whether the tab can be moved to the left.- Parameters:
from
- the current tab's index- Returns:
- true if can be moved
-
canMoveTabToRight
public boolean canMoveTabToRight(int from)
Returns whether the tab can be moved to the right.- Parameters:
from
- the current tab's index- Returns:
- true if can be moved
-
canMoveTabToEnd
public boolean canMoveTabToEnd(int from)
Returns whether the tab can be moved to the end.- Parameters:
from
- the current tab's index- Returns:
- true if can be moved
-
moveTabTo
protected void moveTabTo(int from, int to)
Moves a tab from A to B.- Parameters:
from
- the current positionto
- the new position
-
moveTabToStart
public boolean moveTabToStart(int index)
Moves the tab to the left most position.- Parameters:
index
- the tab's current index- Returns:
- true if successfully moved
-
moveTabToLeft
public boolean moveTabToLeft(int index)
Moves the tab to the left.- Parameters:
index
- the tab's current index- Returns:
- true if successfully moved
-
moveTabToRight
public boolean moveTabToRight(int index)
Moves the tab to the right.- Parameters:
index
- the tab's current index- Returns:
- true if successfully moved
-
moveTabToEnd
public boolean moveTabToEnd(int index)
Moves the tab to the right most position.- Parameters:
index
- the tab's current index- Returns:
- true if successfully moved
-
getTabMoveSubMenu
public BaseMenu getTabMoveSubMenu(int index)
Generates the submenu for moving tabs.- Parameters:
index
- the current tab's index- Returns:
- the submenu
-
addTabChangeListener
public void addTabChangeListener(ChangeListener l)
Adds the listener for changes in tabs.- Parameters:
l
- the listener to add
-
removeTabChangeListener
public void removeTabChangeListener(ChangeListener l)
Removes the listener for changes in tabs.- Parameters:
l
- the listener to remove
-
clearTabChangeListeners
public void clearTabChangeListeners()
Removes all tab change listeners.
-
notifyTabChangeListeners
protected void notifyTabChangeListeners()
Notifies all the tab change listeners
-
addTabClosedListeners
public void addTabClosedListeners(TabClosedListener l)
Adds the listener for closing tabs.- Parameters:
l
- the listener to add
-
removeTabClosedListeners
public void removeTabClosedListeners(TabClosedListener l)
Removes the listener for closing tabs.- Parameters:
l
- the listener to remove
-
clearTabClosedListeners
public void clearTabClosedListeners()
Removes all tab closed listeners.
-
notifyTabClosedListeners
protected void notifyTabClosedListeners(int tabIndex, Component component)
Notifies all the tab closed listeners- Parameters:
tabIndex
- the index of the tab that got closedcomponent
- the component that got removed
-
-