net.infonode.tabbedpanel.titledtab
Class TitledTab

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by net.infonode.tabbedpanel.Tab
                      extended by net.infonode.tabbedpanel.titledtab.TitledTab
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, IconProvider
Direct Known Subclasses:
WindowTab

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:

Most of the properties for the tab can be configured for each of the tab 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.

Version:
$Revision: 1.88 $
Author:
$Author: jesper $
See Also:
TitledTabProperties, TitledTabStateProperties, Serialized Form

Nested Class Summary
private  class TitledTab.HoverablePanel
           
private  class TitledTab.StatePanel
           
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
private  TitledTab.StatePanel currentStatePanel
           
private  TitledTab.StatePanel disabledStatePanel
           
private  TitledTab.HoverablePanel eventPanel
           
private  FocusBorder focusBorder
           
private  java.awt.event.FocusListener focusListener
           
private  TitledTab.StatePanel highlightedStatePanel
           
private  HoverListener hoverListener
           
private  Direction lastTabAreaOrientation
           
private  StackableLayout layout
           
private  java.util.ArrayList mouseListeners
           
private  java.util.ArrayList mouseMotionListeners
           
private  TitledTab.StatePanel normalStatePanel
           
private  TitledTabProperties properties
           
private  PropertyMapTreeListener propertiesListener
           
private  PropertyChangeListener tabbedPanelPropertiesListener
           
private static javax.swing.plaf.PanelUI UI
           
 
Fields inherited from class javax.swing.JComponent
accessibleContext, 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
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
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.
 
Method Summary
 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)
           
private  java.awt.event.MouseEvent convertMouseEvent(java.awt.event.MouseEvent e)
           
private  void doSetEnabled(boolean enabled)
           
private  void doUpdateTab(java.util.Map changes)
           
private  java.awt.Insets getBorderInsets(javax.swing.border.Border border)
           
 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
private  javax.swing.border.Border getInnerBorder(TitledTabStateProperties properties, Direction tabOrientation, int raised, java.awt.Insets maxInsets)
           
 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.
private  Direction getTabAreaOrientation()
           
 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 Note: since ITP 1.5.0 this method will change the enabled property in the TitledTabProperties for this tab.
 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.
private  void updateBorders()
           
private  void updateCurrentStatePanel()
           
private  void updateHoverListener(HoverListener newHoverListener)
           
private  void updateTabAreaOrientation(Direction newDirection)
           
 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, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, 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, transferFocusBackward, 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, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, 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, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UI

private static javax.swing.plaf.PanelUI UI

properties

private TitledTabProperties properties

hoverListener

private HoverListener hoverListener

eventPanel

private TitledTab.HoverablePanel eventPanel

normalStatePanel

private TitledTab.StatePanel normalStatePanel

highlightedStatePanel

private TitledTab.StatePanel highlightedStatePanel

disabledStatePanel

private TitledTab.StatePanel disabledStatePanel

mouseListeners

private java.util.ArrayList mouseListeners

mouseMotionListeners

private java.util.ArrayList mouseMotionListeners

layout

private StackableLayout layout

currentStatePanel

private TitledTab.StatePanel currentStatePanel

focusBorder

private FocusBorder focusBorder

lastTabAreaOrientation

private Direction lastTabAreaOrientation

propertiesListener

private PropertyMapTreeListener propertiesListener

tabbedPanelPropertiesListener

private PropertyChangeListener tabbedPanelPropertiesListener

focusListener

private java.awt.event.FocusListener focusListener
Constructor Detail

TitledTab

public 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.

Parameters:
text - text or null for no text. The text will be applied to the normal state properties
icon - icon or null for no icon. The icon will be applied to the normal state properties
contentComponent - content component or null for no content component
titleComponent - title component or null for no title component. The title component will be applied to all the states
See Also:
TabFactory
Method Detail

contains

public boolean contains(int x,
                        int y)
Overrides:
contains in class javax.swing.JComponent

inside

public boolean inside(int x,
                      int y)
Overrides:
inside in class java.awt.Component

getNormalStateTitleComponent

public javax.swing.JComponent getNormalStateTitleComponent()
Gets the title component for the normal state

Returns:
title component or null if no title component

getHighlightedStateTitleComponent

public javax.swing.JComponent getHighlightedStateTitleComponent()
Gets the title component for the highlighted state

Returns:
title component or null if no title component

getDisabledStateTitleComponent

public javax.swing.JComponent getDisabledStateTitleComponent()
Gets the title component for the disabled state

Returns:
title component or null if no title component

setTitleComponent

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.

Parameters:
titleComponent - the title component or null for no title component

setNormalStateTitleComponent

public void setNormalStateTitleComponent(javax.swing.JComponent titleComponent)
Sets the normal state title component

Parameters:
titleComponent - the title component or null for no title component

setHighlightedStateTitleComponent

public void setHighlightedStateTitleComponent(javax.swing.JComponent titleComponent)
Sets the highlighted state title component

Parameters:
titleComponent - the title component or null for no title component

setDisabledStateTitleComponent

public void setDisabledStateTitleComponent(javax.swing.JComponent titleComponent)
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 class Tab
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 class Tab
Parameters:
enabled - true for enabled, otherwise false

getText

public java.lang.String getText()
Gets the text for the normal state

Returns:
the text or null if no text

setText

public void setText(java.lang.String text)
Sets the text for the normal state

Parameters:
text - the text or null for no text

getIcon

public javax.swing.Icon getIcon()
Gets the icon for the normal state

Specified by:
getIcon in interface IconProvider
Returns:
the icon or null if none

setIcon

public void setIcon(javax.swing.Icon icon)
Sets the icon for the normal state

Parameters:
icon - the icon or null for no icon

getProperties

public TitledTabProperties getProperties()
Gets the TitledTabProperties

Returns:
the TitledTabProperties for this TitledTab

toString

public java.lang.String toString()
Gets the text for the normal state. Same as getText().

Overrides:
toString in class java.awt.Component
Returns:
the text or null if no text
Since:
ITP 1.1.0
See Also:
getText()

addMouseListener

public void addMouseListener(java.awt.event.MouseListener l)
Adds a MouseListener to receive mouse events from this TitledTab.

Overrides:
addMouseListener in class java.awt.Component
Parameters:
l - the MouseListener

removeMouseListener

public void removeMouseListener(java.awt.event.MouseListener l)
Removes a MouseListener

Overrides:
removeMouseListener in class java.awt.Component
Parameters:
l - the MouseListener to remove

getMouseListeners

public java.awt.event.MouseListener[] getMouseListeners()
Gets the mouse listeners

Overrides:
getMouseListeners in class java.awt.Component
Returns:
the mouse listeners

addMouseMotionListener

public void addMouseMotionListener(java.awt.event.MouseMotionListener l)
Adds a MouseMotionListener to receive mouse events from this TitledTab.

Overrides:
addMouseMotionListener in class java.awt.Component
Parameters:
l - the MouseMotionListener

removeMouseMotionListener

public void removeMouseMotionListener(java.awt.event.MouseMotionListener l)
Removes a MouseMotionListener

Overrides:
removeMouseMotionListener in class java.awt.Component
Parameters:
l - the MouseMotionListener to remove

getMouseMotionListeners

public java.awt.event.MouseMotionListener[] getMouseMotionListeners()
Gets the mouse motion listeners

Overrides:
getMouseMotionListeners in class java.awt.Component
Returns:
the mouse motion listeners

getShape

public java.awt.Shape getShape()
Gets the Shape for the current active rendering state.

Overrides:
getShape in class Tab
Returns:
the Shape for the active rendering state, null if no special shape
Since:
ITP 1.2.0

setTabbedPanel

protected void setTabbedPanel(TabbedPanel tabbedPanel)
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 class Tab
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

getBorderInsets

private java.awt.Insets getBorderInsets(javax.swing.border.Border border)

updateBorders

private void updateBorders()

doUpdateTab

private void doUpdateTab(java.util.Map changes)

updateHoverListener

private void updateHoverListener(HoverListener newHoverListener)

getInnerBorder

private javax.swing.border.Border getInnerBorder(TitledTabStateProperties properties,
                                                 Direction tabOrientation,
                                                 int raised,
                                                 java.awt.Insets maxInsets)

getTabAreaOrientation

private Direction getTabAreaOrientation()

updateTabAreaOrientation

private void updateTabAreaOrientation(Direction newDirection)

updateCurrentStatePanel

private void updateCurrentStatePanel()

convertMouseEvent

private java.awt.event.MouseEvent convertMouseEvent(java.awt.event.MouseEvent e)

doSetEnabled

private void doSetEnabled(boolean enabled)

setUI

public void setUI(javax.swing.plaf.PanelUI ui)
Overrides:
setUI in class javax.swing.JPanel

updateUI

public void updateUI()
Overrides:
updateUI in class javax.swing.JPanel

setOpaque

public void setOpaque(boolean opaque)
Overrides:
setOpaque in class javax.swing.JComponent