Class TitledTab
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
,Accessible
,IconProvider
A TitledTab is a tab that has support for text, icon and a custom Swing component (called title component). Titled tab supports several properties that makes it possible to change the look (borders, colors, insets), layout (up, down, left, right).
Titled tab has a line based layout, i.e. the text, icon and title component are laid out in a line. The layout of the tab can be rotated, i.e. the text and the icon will be rotated 90, 180 or 270 degrees. The title component will not be rotated but moved so that the line layout will persist.
A titled tab has 3 rendering states:
- Normal - The tab is selectable but not yet selected
- Highlighted - The tab is either highlighted or selected
- Disabled - The tab is disabled and cannot be selected or highlighted
Note: If only the normal state properties have been configured, the
highlighted and disabled state will automatically use the same properties as for the normal
state, see TitledTabProperties
and TitledTabStateProperties
.
TitledTab implements the IconProvider
interface and
overloads toString() so that both text and icon for the normal state is shown in the
tab drop down list in a tabbed panel.
TitledTab supports mouse hovering. A HoverListener
can be set in the
TitledTabProperties
. The hover listener receives a HoverEvent
when the mouse
enters or exits the tab. The hover event's source will be the affected titled tab.
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
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.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
-
Constructor Summary
ConstructorsConstructorDescriptionTitledTab
(String text, Icon icon, JComponent contentComponent, JComponent titleComponent) Constructs a TitledTab with a text, icon, content component and title component. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a MouseListener to receive mouse events from this TitledTab.void
Adds a MouseMotionListener to receive mouse events from this TitledTab.boolean
contains
(int x, int y) Gets the title component for the disabled stateGets the title component for the highlighted stategetIcon()
Gets the icon for the normal stateGets the mouse listenersGets the mouse motion listenersGets the title component for the normal stateGets the TitledTabPropertiesgetShape()
Gets the Shape for the current active rendering state.getText()
Gets the text for the normal stateboolean
inside
(int x, int y) void
Removes a MouseListenervoid
Removes a MouseMotionListenervoid
setDisabledStateTitleComponent
(JComponent titleComponent) Sets the disabled state title componentvoid
setEnabled
(boolean enabled) Sets if this TitledTab should be enabled or disabledvoid
setHighlighted
(boolean highlighted) Sets if this TitledTab should be highlighted or not.void
setHighlightedStateTitleComponent
(JComponent titleComponent) Sets the highlighted state title componentvoid
Sets the icon for the normal statevoid
setNormalStateTitleComponent
(JComponent titleComponent) Sets the normal state title componentvoid
setOpaque
(boolean opaque) protected void
setTabbedPanel
(TabbedPanel tabbedPanel) Called by the tabbed panel when the tab becomes a member or is no longer a member of the tabbed panelvoid
Sets the text for the normal statevoid
setTitleComponent
(JComponent titleComponent) Sets the title component.void
toString()
Gets the text for the normal state.void
updateUI()
Methods inherited from class net.infonode.tabbedpanel.Tab
addNotify, addTabListener, getContentComponent, getEventComponents, getFocusableComponent, getIndex, getTabbedPanel, isHighlighted, isSelected, removeNotify, removeTabListener, setEventComponent, setEventComponents, setFocusableComponent, setSelected
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString
Methods inherited from class javax.swing.JComponent
addAncestorListener, addVetoableChangeListener, computeVisibleRect, 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, 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, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
Methods inherited from class java.awt.Container
add, add, add, add, add, 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, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, 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, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, 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, 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, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Constructor Details
-
TitledTab
Constructs a TitledTab with a text, icon, content component and title component.- Parameters:
text
- text or null for no text. The text will be applied to the normal state propertiesicon
- icon or null for no icon. The icon will be applied to the normal state propertiescontentComponent
- content component or null for no content componenttitleComponent
- title component or null for no title component. The title component will be applied to all the states- See Also:
-
-
Method Details
-
contains
public boolean contains(int x, int y) - Overrides:
contains
in classJComponent
-
inside
public boolean inside(int x, int y) -
getNormalStateTitleComponent
Gets the title component for the normal state- Returns:
- title component or null if no title component
-
getHighlightedStateTitleComponent
Gets the title component for the highlighted state- Returns:
- title component or null if no title component
-
getDisabledStateTitleComponent
Gets the title component for the disabled state- Returns:
- title component or null if no title component
-
setTitleComponent
Sets the title component.
This method is a convenience method for setting the same title component for all states.
- Parameters:
titleComponent
- the title component or null for no title component
-
setNormalStateTitleComponent
Sets the normal state title component- Parameters:
titleComponent
- the title component or null for no title component
-
setHighlightedStateTitleComponent
Sets the highlighted state title component- Parameters:
titleComponent
- the title component or null for no title component
-
setDisabledStateTitleComponent
Sets the disabled state title component- Parameters:
titleComponent
- the title component or null for no title component
-
setHighlighted
public void setHighlighted(boolean highlighted) Sets if this TitledTab should be highlighted or not.
Note: This will only have effect if this TitledTab is enabled and a member of a tabbed panel.
- Overrides:
setHighlighted
in classTab
- Parameters:
highlighted
- true for highlight, otherwise false
-
setEnabled
public void setEnabled(boolean enabled) Sets if this TitledTab should be enabled or disabled
Note: since ITP 1.5.0 this method will change the enabled property in the
TitledTabProperties
for this tab. Enabled/disabled can be controlled by modifying the property or this method.- Overrides:
setEnabled
in classTab
- Parameters:
enabled
- true for enabled, otherwise false
-
getText
Gets the text for the normal state- Returns:
- the text or null if no text
-
setText
Sets the text for the normal state- Parameters:
text
- the text or null for no text
-
getIcon
Gets the icon for the normal state- Specified by:
getIcon
in interfaceIconProvider
- Returns:
- the icon or null if none
-
setIcon
Sets the icon for the normal state- Parameters:
icon
- the icon or null for no icon
-
getProperties
Gets the TitledTabProperties- Returns:
- the TitledTabProperties for this TitledTab
-
toString
Gets the text for the normal state. Same as getText(). -
addMouseListener
Adds a MouseListener to receive mouse events from this TitledTab.- Overrides:
addMouseListener
in classComponent
- Parameters:
l
- the MouseListener
-
removeMouseListener
Removes a MouseListener- Overrides:
removeMouseListener
in classComponent
- Parameters:
l
- the MouseListener to remove
-
getMouseListeners
Gets the mouse listeners- Overrides:
getMouseListeners
in classComponent
- Returns:
- the mouse listeners
-
addMouseMotionListener
Adds a MouseMotionListener to receive mouse events from this TitledTab.- Overrides:
addMouseMotionListener
in classComponent
- Parameters:
l
- the MouseMotionListener
-
removeMouseMotionListener
Removes a MouseMotionListener- Overrides:
removeMouseMotionListener
in classComponent
- Parameters:
l
- the MouseMotionListener to remove
-
getMouseMotionListeners
Gets the mouse motion listeners- Overrides:
getMouseMotionListeners
in classComponent
- Returns:
- the mouse motion listeners
-
getShape
Gets the Shape for the current active rendering state. -
setTabbedPanel
Description copied from class:Tab
Called by the tabbed panel when the tab becomes a member or is no longer a member of the tabbed panel- Overrides:
setTabbedPanel
in classTab
- Parameters:
tabbedPanel
- tabbed panel that this tab is a member of or null if this tab is no longer a member o a tabbed panel
-
setUI
-
updateUI
public void updateUI() -
setOpaque
public void setOpaque(boolean opaque) - Overrides:
setOpaque
in classJComponent
-