com.tensegrity.gui.swing.control
Class MenuTabbedPane

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JTabbedPane
                  extended bycom.tensegrity.gui.swing.control.MenuTabbedPane
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.swing.SwingConstants
Direct Known Subclasses:
CustomTabbedPane, TabbedMDIComponent

public class MenuTabbedPane
extends javax.swing.JTabbedPane

A simple JTabbedPane wrapper to enable context menus for single tabs.

Version:
$Id: MenuTabbedPane.java,v 1.30 2005/09/13 13:49:01 BurkhardWick Exp $
Author:
Gilles Iachelini
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JTabbedPane
javax.swing.JTabbedPane.AccessibleJTabbedPane, javax.swing.JTabbedPane.ModelListener
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class javax.swing.JTabbedPane
changeEvent, changeListener, model, SCROLL_TAB_LAYOUT, tabPlacement, WRAP_TAB_LAYOUT
 
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 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
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
MenuTabbedPane()
          Constructor for MenuTabbedPane.
MenuTabbedPane(int tabPlacement)
          Constructor for MenuTabbedPane.
 
Method Summary
 java.awt.Component add(java.lang.String title, java.awt.Component c, JPopupMenuSource menu)
          Adds a component to this MenuTabbedPane with the specific title and menu.
protected  JPopupMenuSource getPopupMenuSource(java.awt.Component comp)
          Internal method to retrieve the PopupMenu for a component.
 boolean isFocusBorderEnabled()
          Returns true, if the focus border for the component is enabled
protected  int isOnTab(int x, int y)
          Returns true if the given point coordinates are on one of the tabs of this TabbedPane.
 void markSelectedAsInactive()
          This method marks the selected document as inactive, which means, its still the active document but colored as it would be inactive.
protected  void paintComponent(java.awt.Graphics g)
           
 void remove(java.awt.Component comp)
          Also removes the entry from the menuMap and checks the postcondition.
 void remove(int index)
          Also removes the entry from the menuMap and checks the Postcondition.
 void removeAll()
          Also removes all entries from the menuMap and checks the Postcondition.
 void removeTabAt(int index)
          Also removes the entry from the menuMap and checks the Postcondition.
 void setComponentAt(int index, java.awt.Component component)
          If there is already a Component at that position, the designated menu entry is removed.
 void setFocusBorderEnabled(boolean enable)
          Enables/Disables the focus border for the component
 void setPopupMenuSourceAt(int index, JPopupMenuSource popupmenusource)
          Sets the PopupMenu at index to menu which must greater or equal to 0 and menu not null.
 void setSelectedIndex(int index)
           
 void updateUI()
           
protected  void verifyPostcondition()
          Method verifyPostcondition asserts that the componentCount of this TabbedPane equals the number of elements in the menuMap.
 
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, getTabCount, getTabLayoutPolicy, getTabPlacement, getTabRunCount, getTitleAt, getToolTipText, getToolTipTextAt, getUI, getUIClassID, indexAtLocation, indexOfComponent, indexOfTab, indexOfTab, insertTab, isEnabledAt, paramString, removeChangeListener, setBackgroundAt, setDisabledIconAt, setDisplayedMnemonicIndexAt, setEnabledAt, setForegroundAt, setIconAt, setMnemonicAt, setModel, setSelectedComponent, setTabLayoutPolicy, setTabPlacement, setTitleAt, setToolTipTextAt, setUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MenuTabbedPane

public MenuTabbedPane()
Constructor for MenuTabbedPane.


MenuTabbedPane

public MenuTabbedPane(int tabPlacement)
Constructor for MenuTabbedPane.

Parameters:
tabPlacement - the tab placement hint.
Method Detail

paintComponent

protected void paintComponent(java.awt.Graphics g)

updateUI

public void updateUI()

markSelectedAsInactive

public void markSelectedAsInactive()
This method marks the selected document as inactive, which means, its still the active document but colored as it would be inactive.


setSelectedIndex

public void setSelectedIndex(int index)

add

public java.awt.Component add(java.lang.String title,
                              java.awt.Component c,
                              JPopupMenuSource menu)
Adds a component to this MenuTabbedPane with the specific title and menu.

Parameters:
title - the title to be displayed in this tab.
c - the component to be displayed when this tab is clicked.
menu - an optional PopupMenu to display on the new tab.
Returns:
the component that wraps the added component.

setPopupMenuSourceAt

public void setPopupMenuSourceAt(int index,
                                 JPopupMenuSource popupmenusource)
Sets the PopupMenu at index to menu which must greater or equal to 0 and menu not null.

Parameters:
index - the tab index where the PopupMenu should be set
popupmenusource - the PopupMenu to be displayed for the tab

getPopupMenuSource

protected JPopupMenuSource getPopupMenuSource(java.awt.Component comp)
Internal method to retrieve the PopupMenu for a component.

Parameters:
comp - the component for which you want the PopupMenu.
Returns:
a JPopupMenu for the given component, or null if no such menu was found.

isOnTab

protected int isOnTab(int x,
                      int y)
Returns true if the given point coordinates are on one of the tabs of this TabbedPane.

Parameters:
x - the x-coordinate.
y - the y-coordinate.
Returns:
boolean a boolean that indicates whether a given point is on a tab or not.

remove

public void remove(java.awt.Component comp)
Also removes the entry from the menuMap and checks the postcondition.

See Also:
verifyPostcondition(), Container.remove(Component)

remove

public void remove(int index)
Also removes the entry from the menuMap and checks the Postcondition.

See Also:
verifyPostcondition(), Container.remove(int)

removeAll

public void removeAll()
Also removes all entries from the menuMap and checks the Postcondition.

See Also:
verifyPostcondition(), Container.removeAll()

removeTabAt

public void removeTabAt(int index)
Also removes the entry from the menuMap and checks the Postcondition.

See Also:
verifyPostcondition(), JTabbedPane.removeTabAt(int)

setComponentAt

public void setComponentAt(int index,
                           java.awt.Component component)
If there is already a Component at that position, the designated menu entry is removed. Then checks the postcondition.

See Also:
verifyPostcondition(), JTabbedPane.setComponentAt(int, Component)

verifyPostcondition

protected void verifyPostcondition()
Method verifyPostcondition asserts that the componentCount of this TabbedPane equals the number of elements in the menuMap. If this is no longer the case, something has been gone wrong very badly.


setFocusBorderEnabled

public void setFocusBorderEnabled(boolean enable)
Enables/Disables the focus border for the component

Parameters:
enable - true, to enable the focus border

isFocusBorderEnabled

public boolean isFocusBorderEnabled()
Returns true, if the focus border for the component is enabled

Returns:
true, if the focus border for the component is enabled


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.