edu.mssm.crover.beans
Class LooseTabbedPane

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--edu.mssm.crover.beans.LooseTabbedPane
All Implemented Interfaces:
javax.accessibility.Accessible, javax.swing.event.ChangeListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class LooseTabbedPane
extends javax.swing.JPanel
implements javax.swing.event.ChangeListener

A LooseTabbedPane is a TabbedPane whose elements can be detached to be contained in independant windows, or in internal frames of a desktopPane inside the tabbedpane. A detached element can be re-integrated in the tabbedPane, back and forth, at the user convenience. This GUI provides for the comfort of a TabbedPane, that is the elements share the same space on the desktop, and so the useful space is best used compared to independant windows. But the LooseTabbedPane also allows each tab to be extracted to that the user can work with two, or more, of the tabs at the same time. LooseTabbedPane also supports for desk tabs. These tabs contain a desktop that can contain internalFrames. Each tab of the LooseTabbedPane (but desk tabs) can be moved to an internal frame of a given desk. LooseTabbedPane now provides a way to determine which tab element has the focus. The events are fired only when the focus is actually transferred from a tab element to another. This works without regard of the appearance of the tab. For instance, when a tab is detached, the creation of the independant window is not considered a transfer of tab-focus because it is still the same tab that has the tab-focus. The tab-focus events are also fired when the JInternalFrame that contains a tab is activated (and this tab did not previously have the tab-focus).

See Also:
For an example and test of this GUI element, run main()., Serialized Form

Nested Class Summary
protected  class LooseTabbedPane.AttachedFrame
          AttachedFrame class contain the content of the tab in the detached state.
protected  class LooseTabbedPane.DesktopElement
           
protected  class LooseTabbedPane.FlyingElement
          FlyingElements are added to the TabbedPane in place of a component.
 
Field Summary
 boolean buttonsInTabs
          Toggle the display of interaction buttons immediately following the tab content.
static int EMBED_STATE
          attached state: the content is rendered in the tab.
 java.util.Vector focus_listeners
           
static int INDEPENDANT_STATE
          detached state: the content is rendered in an independant window.
 
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
LooseTabbedPane()
           
 
Method Summary
 void addFocusListener(TabFocusListener fl)
           
 void attach()
          Attach the content associated to this tab inside the tabbedPane.
 void attachedFrameFocusChange(java.lang.String new_tab_title)
           
 void cleanDesk(java.lang.String title)
          Clean a desk-tab.
 void detach()
          Detach the content associated to this tab from the tabbedPane.
 void fireFocusEvent(int type, java.lang.String tab_title)
          Dispacth this event to all the registered listeners.
 LooseTabbedPane.DesktopElement getDesk(java.lang.String title)
          Returns the DesktopElement contained in this tab.
protected  LooseTabbedPane.FlyingElement getSelectedNoDesk(java.lang.String action_description)
          Returns a the selected FlyingElement.
 javax.swing.JTabbedPane getTabbedPane()
          Returns the JTabbedPane.
 void insertDesk(java.lang.String title, javax.swing.Icon icon, java.lang.String tip, int position)
          Inserts a new virtual desk in this LooseTabbedPane.
 void insertTab(java.lang.String title, javax.swing.Icon icon, java.awt.Component comp, java.lang.String tip, int position, int state)
          Inserts comp in the LooseTabbedPane.
static void main(java.lang.String[] args)
          Builds a full example of use.
protected static java.awt.Component makeTextPanel(java.lang.String text)
           
 void move(java.lang.String desk_title)
          Moves the content associated to this tab from the tabbedPane.
 void removeDesk(java.lang.String title)
          Remove a desk-tab.
 void removeFocusListener(TabFocusListener fl)
           
 void selectNext()
          Selects the next tab of this tabbedPane.
 void selectPrevious()
          Selects the previous tab of this tabbedPane.
 void stateChanged(javax.swing.event.ChangeEvent event)
          Examine the JTabbedPane events and fire the TabFocusEvent when needed.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
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, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, 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
add, add, add, add, add, 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, remove, remove, removeAll, 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
 

Field Detail

EMBED_STATE

public static final int EMBED_STATE
attached state: the content is rendered in the tab.

See Also:
Constant Field Values

INDEPENDANT_STATE

public static final int INDEPENDANT_STATE
detached state: the content is rendered in an independant window.

See Also:
Constant Field Values

focus_listeners

public java.util.Vector focus_listeners

buttonsInTabs

public boolean buttonsInTabs
Toggle the display of interaction buttons immediately following the tab content. The buttons allow the user to attach and detach the content of the time without external control. They could be useful at development time but are better replaced latter by external controls (these one can be located at a fixed position).

Constructor Detail

LooseTabbedPane

public LooseTabbedPane()
Method Detail

getTabbedPane

public javax.swing.JTabbedPane getTabbedPane()
Returns the JTabbedPane.


selectNext

public void selectNext()
Selects the next tab of this tabbedPane. If no next element is present, the selected tab does not change.


selectPrevious

public void selectPrevious()
Selects the previous tab of this tabbedPane. If no previous element is present, the selected tab does not change.


attach

public void attach()
Attach the content associated to this tab inside the tabbedPane. Does nothing when the content is already embed in the pane or when the tabbedPane is empty.


detach

public void detach()
Detach the content associated to this tab from the tabbedPane. The content is transfered to a JFrame (other window). Does nothing when the content is already detached or when the tabbedPane is empty.


getSelectedNoDesk

protected LooseTabbedPane.FlyingElement getSelectedNoDesk(java.lang.String action_description)
Returns a the selected FlyingElement. Returns null if the selected tab is a desk (warn the user), or something else (do not warn the user).


move

public void move(java.lang.String desk_title)
Moves the content associated to this tab from the tabbedPane. The content is transfered to a JInternalFrame in the JDeskPane the name is passed in argument. Does nothing when the content is already detached, when the desk does not exist, or when the tabbedPane is empty. Warns the user through a dialog when the tab requested to be moved is a desk tab.


insertTab

public void insertTab(java.lang.String title,
                      javax.swing.Icon icon,
                      java.awt.Component comp,
                      java.lang.String tip,
                      int position,
                      int state)
Inserts comp in the LooseTabbedPane.

Parameters:
title - of this new Tab.
comp - The component to add for the new Tab.
position - of insertion. 0 is first.
tip - The tip text for this tab.
state - The state of this tab: EMBED_STATE (attached) or INDEPENDANT_STATE (detached, own window).
icon - graphical representation of the type of this tab

insertDesk

public void insertDesk(java.lang.String title,
                       javax.swing.Icon icon,
                       java.lang.String tip,
                       int position)
Inserts a new virtual desk in this LooseTabbedPane. The desktop is inserted under a tab of hte specified title.

Parameters:
title - of this new desk-tab.
position - of insertion. 0 is first.
tip - The tip text for this tab.

cleanDesk

public void cleanDesk(java.lang.String title)
Clean a desk-tab. The internal frames contained in the desk are all reattached to their tab, then the desk is removed.


removeDesk

public void removeDesk(java.lang.String title)
Remove a desk-tab. The internal frames contained in the desk are all reattached to their tab.


stateChanged

public void stateChanged(javax.swing.event.ChangeEvent event)
Examine the JTabbedPane events and fire the TabFocusEvent when needed. Desktop elements are never considered to gain the focus.

Specified by:
stateChanged in interface javax.swing.event.ChangeListener

attachedFrameFocusChange

public void attachedFrameFocusChange(java.lang.String new_tab_title)

fireFocusEvent

public void fireFocusEvent(int type,
                           java.lang.String tab_title)
Dispacth this event to all the registered listeners.


getDesk

public LooseTabbedPane.DesktopElement getDesk(java.lang.String title)
Returns the DesktopElement contained in this tab.


addFocusListener

public void addFocusListener(TabFocusListener fl)

removeFocusListener

public void removeFocusListener(TabFocusListener fl)

main

public static void main(java.lang.String[] args)
Builds a full example of use. See the code and run it to see how everything works.


makeTextPanel

protected static java.awt.Component makeTextPanel(java.lang.String text)


Copyright @ 2003 Mount Sinai School of Medicine. All Rights Reserved.