Package megamek.common.ui
Class EnhancedTabbedPane
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JTabbedPane
megamek.common.ui.EnhancedTabbedPane
- All Implemented Interfaces:
ImageObserver,MenuContainer,Serializable,Accessible,SwingConstants
- Direct Known Subclasses:
EntityViewPane
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic interfaceInterface for customizing tab detachment behaviorstatic interfaceInterface for listeners that are notified of tab state changesNested classes/interfaces inherited from class javax.swing.JTabbedPane
JTabbedPane.AccessibleJTabbedPane, JTabbedPane.ModelListenerNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested 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_LAYOUTFields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTHFields 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
ConstructorsConstructorDescriptionEnhancedTabbedPane(boolean tabDetachingEnabled, boolean tabReorderingEnabled) EnhancedTabbedPane(List<JButton> actionButtons, boolean tabDetachingEnabled, boolean tabReorderingEnabled) Creates a new EnhancedTabbedPane with closable, draggable tabs and action buttons. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddActionButton(JButton button) Adds a button to the action buttons panelintaddCloseableTab(String title, Icon icon, Component component) intaddCloseableTab(String title, Icon icon, Component component, int tabIndex) Adds a closeable tab to this tabbed paneprotected voidaddHoverEffect(JButton button) Adds hover effect to a buttonvoidvoidAdds a listener that will be notified of tab state changesbooleancontainsTab(Component component) Checks if a component is currently hosted by this pane, including detached tab windows.voidDetaches a tab from the pane into a floating windowvoiddetachTab(CloseableTab tab, Point location) Deprecated, for removal: This API element is subject to removal in a future version.voiddispose()protected voidfireTabDetached(Window window, DetachedTabInfo tabInfo) protected booleanfireTabDetaching(int tabIndex, Component component) protected voidfireTabMoved(int oldIndex, int tabIndex, Component component) protected voidfireTabReattached(int tabIndex, Component component) protected booleanfireTabReattaching(DetachedTabInfo tabInfo) protected voidfireTabRemoved(int tabIndex, Component component) Deprecated, for removal: This API element is subject to removal in a future version.Deprecated, for removal: This API element is subject to removal in a future version.Gets the current order of tabs by their titles.getTitleAt(int index) Returns the tab title atindex.booleanChecks if there are any detached tabsvoidOverride insertTab to ensure button positioning is updatedbooleanisTabSelected(Component component) Deprecated, for removal: This API element is subject to removal in a future version.protected voidvoidProgrammatically reattaches all detached tabsvoidremove(int index) Override remove to ensure button positioning is updatedvoidremoveActionButton(JButton button) Deprecated, for removal: This API element is subject to removal in a future version.voidDeprecated, for removal: This API element is subject to removal in a future version.voidvoidbooleanRemoves a component from this pane, closing its floating window if the tab is currently detached.booleanDeprecated, for removal: This API element is subject to removal in a future version.voidsetActionButtons(JButton... actionButtons) Deprecated, for removal: This API element is subject to removal in a future version.voidsetActionButtonsAlignAfterTabs(boolean alignAfterTabs) Deprecated, for removal: This API element is subject to removal in a future version.voidsetDetachedTabPrefixTitle(DetachedTabInfo detachedTab, String prefix) Sets the title prefix for a detached tab windowvoidsetDetachedTabsPrefixTitle(String prefix) Sets the title prefix for all the detached tab windowsbooleansetDetachedTabTitle(JFrame frame, String title) Deprecated, for removal: This API element is subject to removal in a future version.voidSets a custom factory for creating detached tab windowsvoidsetDockGroupId(String dockGroupId) Sets the dock group ID for this tabbed pane.voidsetMinimumTabsCount(int minimumTabsCount) Deprecated, for removal: This API element is subject to removal in a future version.voidsetTabComponentAt(int index, Component component) voidsetTabDetachingEnabled(boolean enabled) Deprecated, for removal: This API element is subject to removal in a future version.voidDeprecated, for removal: This API element is subject to removal in a future version.voidsetTabLayoutPolicy(int tabLayoutPolicy) voidsetTabOrder(List<String> desiredOrder) Sets the order of tabs based on a list of tab titles.voidsetTabReorderingEnabled(boolean enabled) Deprecated, for removal: This API element is subject to removal in a future version.voidsetTitleAt(int index, String title) Sets the title atindextotitlewhich can benull.voidupdateUI()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, getToolTipText, getToolTipTextAt, getUI, getUIClassID, indexAtLocation, indexOfComponent, indexOfTab, indexOfTab, indexOfTabComponent, isEnabledAt, paramString, remove, removeChangeListener, removeTabAt, setBackgroundAt, setComponentAt, setDisabledIconAt, setDisplayedMnemonicIndexAt, setEnabledAt, setForegroundAt, setIconAt, setMnemonicAt, setModel, setSelectedComponent, setSelectedIndex, setTabPlacement, setToolTipTextAt, setUIMethods inherited from class javax.swing.JComponent
addAncestorListener, 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, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, 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, updateMethods 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, validateTreeMethods 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
-
Constructor Details
-
EnhancedTabbedPane
public EnhancedTabbedPane() -
EnhancedTabbedPane
public EnhancedTabbedPane(boolean tabDetachingEnabled, boolean tabReorderingEnabled) -
EnhancedTabbedPane
public EnhancedTabbedPane(List<JButton> actionButtons, boolean tabDetachingEnabled, boolean tabReorderingEnabled) Creates a new EnhancedTabbedPane with closable, draggable tabs and action buttons.- Parameters:
actionButtons- Action Buttons
-
-
Method Details
-
setTabDetachingEnabled
Deprecated, for removal: This API element is subject to removal in a future version.Sets whether tabs can be detached from the pane- Parameters:
enabled- true to enable tab detaching, false to disable
-
setTabReorderingEnabled
Deprecated, for removal: This API element is subject to removal in a future version.Sets whether tabs can be reordered by dragging- Parameters:
enabled- true to enable tab reordering, false to disable
-
setActionButtonsAlignAfterTabs
@Deprecated(since="0.51.0", forRemoval=true) public void setActionButtonsAlignAfterTabs(boolean alignAfterTabs) Deprecated, for removal: This API element is subject to removal in a future version.Sets whether action buttons should be aligned after the tabs or on the right side of the window- Parameters:
alignAfterTabs- true to align after tabs, false to align on the right side
-
setMinimumTabsCount
Deprecated, for removal: This API element is subject to removal in a future version.Sets the minimum number of tabs that can't be detached- Parameters:
minimumTabsCount- The minimum number of tabs that can't be detached
-
setDockGroupId
Sets the dock group ID for this tabbed pane. This ID is used to group tabbed panels that can share tabs between each other.- Parameters:
dockGroupId- The ID to set for this tabbed pane (used for cross-pane docking)
-
getDockGroupId
Deprecated, for removal: This API element is subject to removal in a future version.Returns the dock group ID for this tabbed pane- Returns:
- The ID of the dock group for this tabbed pane, or null if not set
-
setDetachedWindowFactory
Sets a custom factory for creating detached tab windows- Parameters:
factory- The factory to call when creating a detached window
-
getDetachedWindowFactory
@Deprecated(since="0.51.0", forRemoval=true) public EnhancedTabbedPane.DetachedWindowFactory getDetachedWindowFactory()Deprecated, for removal: This API element is subject to removal in a future version.Gets the current detached window factory- Returns:
- The current detached window factory or null if none is set
-
setTabDetachmentHandler
@Deprecated(since="0.51.0", forRemoval=true) public void setTabDetachmentHandler(EnhancedTabbedPane.TabDetachmentHandler handler) Deprecated, for removal: This API element is subject to removal in a future version.Sets a custom handler for tab detachment operations- Parameters:
handler- The handler to call when a tab is being detached
-
removeActionButtons
Deprecated, for removal: This API element is subject to removal in a future version.Removes all action buttons from the tabbed pane -
setActionButtons
Deprecated, for removal: This API element is subject to removal in a future version.Set buttons to the action buttons panel -
addActionButton
Adds a button to the action buttons panel -
removeActionButton
Deprecated, for removal: This API element is subject to removal in a future version.Removes a button from the action buttons panel -
getTabOrder
Gets the current order of tabs by their titles.- Returns:
- A list of tab titles in their current display order.
-
setTabOrder
Sets the order of tabs based on a list of tab titles. Tabs indesiredOrderthat are currently present will be reordered. Tabs present in the pane but not indesiredOrderwill be appended to the end, maintaining their relative order among themselves. Tabs indesiredOrderbut not currently present in the pane are ignored.- Parameters:
desiredOrder- A list of tab titles representing the desired order.
-
addTabStateListener
Adds a listener that will be notified of tab state changes- Parameters:
listener- The listener to add
-
removeTabStateListener
@Deprecated(since="0.51.0", forRemoval=true) public boolean removeTabStateListener(EnhancedTabbedPane.TabStateListener listener) Deprecated, for removal: This API element is subject to removal in a future version.Removes a previously added tab state listener- Parameters:
listener- The listener to remove- Returns:
- true if the listener was found and removed
-
fireTabMoved
-
fireTabDetaching
-
fireTabDetached
-
fireTabReattaching
-
fireTabReattached
-
fireTabRemoved
-
addHoverEffect
Adds hover effect to a button- Parameters:
button- The button to enhance with hover effect
-
hasDetachedTabs
public boolean hasDetachedTabs()Checks if there are any detached tabs- Returns:
- true if there are detached tabs, false otherwise
-
containsTab
Checks if a component is currently hosted by this pane, including detached tab windows.- Parameters:
component- The component to find- Returns:
- true if the component is attached or detached from this pane
-
removeTab
Removes a component from this pane, closing its floating window if the tab is currently detached.- Parameters:
component- The component to remove- Returns:
- true if the component was found and removed
-
setDetachedTabTitle
@Deprecated(since="0.51.0", forRemoval=true) public boolean setDetachedTabTitle(JFrame frame, String title) Deprecated, for removal: This API element is subject to removal in a future version.Updates the title of a detached tab window containing the given editor- Parameters:
frame- The editor to find in detached windowstitle- The new title to set- Returns:
- true if a detached window was found and updated, false otherwise
-
setDetachedTabsPrefixTitle
Sets the title prefix for all the detached tab windows- Parameters:
prefix- The prefix to set
-
setDetachedTabPrefixTitle
Sets the title prefix for a detached tab window- Parameters:
detachedTab- The detached tab infoprefix- The prefix to set
-
addCloseableTab
-
addCloseableTab
Adds a closeable tab to this tabbed pane- Parameters:
title- The title of the tabicon- theIconfor the tab.component- The component to display in the tabtabIndex- The index at which to add the tab- Returns:
- The index of the newly added tab
-
getTitleAt
Returns the tab title atindex.- Overrides:
getTitleAtin classJTabbedPane- Parameters:
index- the index of the item being queried- Returns:
- the title at
index - See Also:
-
setTitleAt
Sets the title atindextotitlewhich can benull. The title is not shown if a tab component for this tab was specified.- Overrides:
setTitleAtin classJTabbedPane- Parameters:
index- the tab index where the title should be settitle- the title to be displayed in the tab- See Also:
-
detachTab
@Deprecated(since="0.51.0", forRemoval=true) public void detachTab(CloseableTab tab, Point location) Deprecated, for removal: This API element is subject to removal in a future version.Detaches a tab from the pane and creates a floating window- Parameters:
tab- An CloseableTab instance representing the tab to detachlocation- The screen location where to position the new window
-
detachTab
Detaches a tab from the pane into a floating window- Parameters:
tabIndex- The index of the tab to detachlocation- The screen location for the detached window
-
isTabSelected
Deprecated, for removal: This API element is subject to removal in a future version.Checks if the specified component is the currently selected tab- Parameters:
component- The component to check
-
reattachAllTabs
public void reattachAllTabs()Programmatically reattaches all detached tabs -
paintComponent
- Overrides:
paintComponentin classJComponent
-
updateUI
public void updateUI()- Overrides:
updateUIin classJTabbedPane
-
insertTab
Override insertTab to ensure button positioning is updated- Overrides:
insertTabin classJTabbedPane
-
remove
public void remove(int index) Override remove to ensure button positioning is updated- Overrides:
removein classJTabbedPane
-
removeAll
public void removeAll()- Overrides:
removeAllin classJTabbedPane
-
setTabComponentAt
- Overrides:
setTabComponentAtin classJTabbedPane
-
setTabLayoutPolicy
public void setTabLayoutPolicy(int tabLayoutPolicy) - Overrides:
setTabLayoutPolicyin classJTabbedPane
-
addNotify
public void addNotify()- Overrides:
addNotifyin classJComponent
-
removeNotify
public void removeNotify()- Overrides:
removeNotifyin classJComponent
-
dispose
public void dispose()
-