public class TitledTab extends Tab implements 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:
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.
javax.swing.JPanel.AccessibleJPanel
javax.swing.JComponent.AccessibleJComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Constructor and Description |
---|
TitledTab(java.lang.String text,
javax.swing.Icon icon,
javax.swing.JComponent contentComponent,
javax.swing.JComponent titleComponent)
Constructs a TitledTab with a text, icon, content component and title component.
|
Modifier and Type | Method and Description |
---|---|
void |
addMouseListener(java.awt.event.MouseListener l)
Adds a MouseListener to receive mouse events from this TitledTab.
|
void |
addMouseMotionListener(java.awt.event.MouseMotionListener l)
Adds a MouseMotionListener to receive mouse events from this TitledTab.
|
boolean |
contains(int x,
int y) |
javax.swing.JComponent |
getDisabledStateTitleComponent()
Gets the title component for the disabled state
|
javax.swing.JComponent |
getHighlightedStateTitleComponent()
Gets the title component for the highlighted state
|
javax.swing.Icon |
getIcon()
Gets the icon for the normal state
|
java.awt.event.MouseListener[] |
getMouseListeners()
Gets the mouse listeners
|
java.awt.event.MouseMotionListener[] |
getMouseMotionListeners()
Gets the mouse motion listeners
|
javax.swing.JComponent |
getNormalStateTitleComponent()
Gets the title component for the normal state
|
TitledTabProperties |
getProperties()
Gets the TitledTabProperties
|
java.awt.Shape |
getShape()
Gets the Shape for the current active rendering state.
|
java.lang.String |
getText()
Gets the text for the normal state
|
boolean |
inside(int x,
int y) |
void |
removeMouseListener(java.awt.event.MouseListener l)
Removes a MouseListener
|
void |
removeMouseMotionListener(java.awt.event.MouseMotionListener l)
Removes a MouseMotionListener
|
void |
setDisabledStateTitleComponent(javax.swing.JComponent titleComponent)
Sets the disabled state title component
|
void |
setEnabled(boolean enabled)
Sets if this TitledTab should be enabled or disabled
|
void |
setHighlighted(boolean highlighted)
Sets if this TitledTab should be highlighted or not.
|
void |
setHighlightedStateTitleComponent(javax.swing.JComponent titleComponent)
Sets the highlighted state title component
|
void |
setIcon(javax.swing.Icon icon)
Sets the icon for the normal state
|
void |
setNormalStateTitleComponent(javax.swing.JComponent titleComponent)
Sets the normal state title component
|
void |
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 panel
|
void |
setText(java.lang.String text)
Sets the text for the normal state
|
void |
setTitleComponent(javax.swing.JComponent titleComponent)
Sets the title component.
|
void |
setUI(javax.swing.plaf.PanelUI ui) |
java.lang.String |
toString()
Gets the text for the normal state.
|
void |
updateUI() |
addNotify, addTabListener, getContentComponent, getEventComponents, getFocusableComponent, getIndex, getTabbedPanel, isHighlighted, isSelected, removeNotify, removeTabListener, setEventComponent, setEventComponents, setFocusableComponent, setSelected
getAccessibleContext, getUI, getUIClassID, paramString
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
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
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, getPeer, 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, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, transferFocus, transferFocusBackward, transferFocusUpCycle
public TitledTab(java.lang.String text, javax.swing.Icon icon, javax.swing.JComponent contentComponent, javax.swing.JComponent titleComponent)
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 statesTabFactory
public boolean contains(int x, int y)
contains
in class javax.swing.JComponent
public boolean inside(int x, int y)
inside
in class java.awt.Component
public javax.swing.JComponent getNormalStateTitleComponent()
public javax.swing.JComponent getHighlightedStateTitleComponent()
public javax.swing.JComponent getDisabledStateTitleComponent()
public void setTitleComponent(javax.swing.JComponent titleComponent)
Sets the title component.
This method is a convenience method for setting the same title component for all states.
titleComponent
- the title component or null for no title componentpublic void setNormalStateTitleComponent(javax.swing.JComponent titleComponent)
titleComponent
- the title component or null for no title componentpublic void setHighlightedStateTitleComponent(javax.swing.JComponent titleComponent)
titleComponent
- the title component or null for no title componentpublic void setDisabledStateTitleComponent(javax.swing.JComponent titleComponent)
titleComponent
- the title component or null for no title componentpublic 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.
setHighlighted
in class Tab
highlighted
- true for highlight, otherwise falsepublic 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.
setEnabled
in class Tab
enabled
- true for enabled, otherwise falsepublic java.lang.String getText()
public void setText(java.lang.String text)
text
- the text or null for no textpublic javax.swing.Icon getIcon()
getIcon
in interface IconProvider
public void setIcon(javax.swing.Icon icon)
icon
- the icon or null for no iconpublic TitledTabProperties getProperties()
public java.lang.String toString()
toString
in class java.awt.Component
getText()
public void addMouseListener(java.awt.event.MouseListener l)
addMouseListener
in class java.awt.Component
l
- the MouseListenerpublic void removeMouseListener(java.awt.event.MouseListener l)
removeMouseListener
in class java.awt.Component
l
- the MouseListener to removepublic java.awt.event.MouseListener[] getMouseListeners()
getMouseListeners
in class java.awt.Component
public void addMouseMotionListener(java.awt.event.MouseMotionListener l)
addMouseMotionListener
in class java.awt.Component
l
- the MouseMotionListenerpublic void removeMouseMotionListener(java.awt.event.MouseMotionListener l)
removeMouseMotionListener
in class java.awt.Component
l
- the MouseMotionListener to removepublic java.awt.event.MouseMotionListener[] getMouseMotionListeners()
getMouseMotionListeners
in class java.awt.Component
public java.awt.Shape getShape()
protected void setTabbedPanel(TabbedPanel tabbedPanel)
Tab
setTabbedPanel
in class Tab
tabbedPanel
- tabbed panel that this tab is a member of or null if this tab is no
longer a member o a tabbed panelpublic void setUI(javax.swing.plaf.PanelUI ui)
setUI
in class javax.swing.JPanel
public void updateUI()
updateUI
in class javax.swing.JPanel
public void setOpaque(boolean opaque)
setOpaque
in class javax.swing.JComponent