cds.gui
Class CTabbedPane

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JTabbedPane
                  extended bycds.gui.CTabbedPane
All Implemented Interfaces:
javax.accessibility.Accessible, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.io.Serializable, javax.swing.SwingConstants

public class CTabbedPane
extends javax.swing.JTabbedPane
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener

CTabbedPane class

Version:
1.0 July 2003
Author:
Marc Wenger/CDS
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
(package private)  java.lang.String actionCommand
           
(package private)  java.awt.event.ActionListener actionListener
           
private  int currentDragTab
           
(package private)  java.awt.Color[] iconColors
           
private  int pressedTab
           
private  Tab selectedTab
           
private static java.util.ArrayList tabbedPanes
           
private  TabList tabs
           
 
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.Container
 
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
CTabbedPane()
          Constructor
CTabbedPane(int tabPlacement)
          Constructor
CTabbedPane(int tabPlacement, int tabLayoutPolicy)
          Constructor
 
Method Summary
 void add(java.awt.Component p, java.lang.String name, int pos)
          Add a component to the TabbedPane at the given position
 void add(java.awt.Component p, java.lang.String name, java.lang.String tip)
          Add a component at the end of the current component list
 void addActionListener(java.awt.event.ActionListener al)
          Add an action listener to the listener list
 void addTab(java.lang.String name, java.awt.Component p)
          Add a component at the end of the current component list
 void addTab(java.lang.String name, javax.swing.Icon ic, java.awt.Component p)
          Add a component at the end of the current component list
 void addTab(java.lang.String name, javax.swing.Icon ic, java.awt.Component p, java.lang.String tip)
          Add a component at the end of the current component list
 void attach_action(java.awt.event.ActionEvent e)
          Listener action method to re-attach the designated tab
 void attach_action(java.awt.event.WindowEvent e)
          Listener action method to re-attach the designated tab, when clicking on the closing button of the window manager
 void attach_all_action()
          Listener method to re-attach all frames coming from the same TabbedPane object than the one clicked
private  void attachFrame(javax.swing.JFrame frame)
          Re-attach the content of a frame in its tabbedPane
private  void attachFrame(Tab t)
          Re-attach the given tab
static void clean_desk()
          Listener method to reattach all the frames coming from all tabbed Panes
private  void detachTab(int n)
          Detach the tab defined by its index
 void fireEvent(int type, int orig, int dest)
          Fire an event when moving a tab
 java.awt.Component getComponentAt(java.lang.String tabName)
          Return the main component of a tab designated by its name
 java.awt.Component getSelectedTab()
          Return the main component in the currently selected tab.
 java.awt.Component getTab(java.lang.String tabName)
          Return the main component of a tab designated by its name
private  void init()
          Initialisations specific to the CTabbedPane
protected  int isInIcon(int x, int y)
          Checks if a coordinate is in the Icon in a tab
protected  int isInTab(int x, int y)
          Checks if a coordinate is in a tab
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseDragged(java.awt.event.MouseEvent e)
          Mouse dragged.
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mouseMoved(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
          mouse pressed: define the origin when dragging
 void mouseReleased(java.awt.event.MouseEvent e)
          mouse released:
defines the end tab when dragging. depending on the position (first or second half of the tab), the dragged tab will be inserted left or right of the current one defines the tab to detach when the mouse button was pushed in the icon
private  void moveTab(int orig, int dest)
          Move a tab in the tabbedPane
 void removeActionListener(java.awt.event.ActionListener al)
          Remove an action listener from the listener list
 void setActionCommand(java.lang.String actionCommand)
          Sets an action command name
 void setSelectedName(java.lang.String tabName)
          Select the tab according to its name.
 void startBlink(java.lang.String tabName)
           
 void stopBlink(java.lang.String tabName)
           
 
Methods inherited from class javax.swing.JTabbedPane
add, add, add, add, add, addChangeListener, 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, remove, remove, removeAll, removeChangeListener, removeTabAt, setBackgroundAt, setComponentAt, setDisabledIconAt, setDisplayedMnemonicIndexAt, setEnabledAt, setForegroundAt, setIconAt, setMnemonicAt, setModel, setSelectedComponent, setSelectedIndex, setTabLayoutPolicy, setTabPlacement, setTitleAt, setToolTipTextAt, 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, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, ge|VetoebLeChangeListeners, 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
addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countCoÝpone.ts. 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, sedL´cale, 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

iconColors

java.awt.Color[] iconColors

tabbedPanes

private static java.util.ArrayList tabbedPanes

tabs

private TabList tabs

pressedTab

private int pressedTab

currentDragTab

private int currentDragTab

selectedTab

private Tab selectedTab

actionListener

java.awt.event.ActionListener actionListener

actionCommand

java.lang.String actionCommand
Constructor Detail

CTabbedPane

public CTabbedPane()
Constructor


CTabbedPane

public CTabbedPane(int tabPlacement)
Constructor

Parameters:
tabPlacement - Position of the tabs: TabbedPane.TOP, JTabbedPane.BOTTOM, JTabbedPane.LEFT, or JTabbedPane.RIGHT

CTabbedPane

public CTabbedPane(int tabPlacement,
                   int tabLayoutPolicy)
Constructor

Parameters:
tabPlacement - Position of the tabs: TabbedPane.TOP, JTabbedPane.BOTTOM, JTabbedPane.LEFT, or JTabbedPane.RIGHT
tabLayoutPolicy - Policy to display the tabs when they do not fit in one line : JTabbedPane.WRAP_TAB_LAYOUT or JTabbedPane.SCROLL_TAB_LAYOUT
Method Detail

init

private void init()
Initialisations specific to the CTabbedPane


addTab

public void addTab(java.lang.String name,
                   java.awt.Component p)
Add a component at the end of the current component list

Parameters:
name - name of this tab
p - component to add as a tab

addTab

public void addTab(java.lang.String name,
                   javax.swing.Icon ic,
                   java.awt.Component p)
Add a component at the end of the current component list

Parameters:
name - name of this tab
ic - Icone object. NOT USED by this class, which has its own Icon.
p - component to add as a tab

addTab

public void addTab(java.lang.String name,
                   javax.swing.Icon ic,
                   java.awt.Component p,
                   java.lang.String tip)
Add a component at the end of the current component list

Parameters:
p - component to add as a tab
ic - Icone object. NOT USED by this class, which has its own Icon.
name - name of this tab
tip - text for the tooltip to be displayed

add

public void add(java.awt.Component p,
                java.lang.String name,
                java.lang.String tip)
Add a component at the end of the current component list

Parameters:
p - component to add as a tab
name - name of this tab
tip - text for the tooltip to be displayed

add

public void add(java.awt.Component p,
                java.lang.String name,
                int pos)
Add a component to the TabbedPane at the given position

Parameters:
p - component to add as a tab
name - name of this tab
pos - position where to insert the component

setSelectedName

public void setSelectedName(java.lang.String tabName)
Select the tab according to its name. It the tab is still in the tabbedPane, it will be selected. If it is in a frame, this frame will be brought to front.
This is the CTabbedPanel version of setSelectedComponent() or setSelectedIndex() methods.

Parameters:
tabName - name of the tab

getSelectedTab

public java.awt.Component getSelectedTab()
Return the main component in the currently selected tab. It can be either in the tabbedPane or in a detached frame

Returns:
the component (generally a JPanel)

getComponentAt

public java.awt.Component getComponentAt(java.lang.String tabName)
Return the main component of a tab designated by its name

Parameters:
tabName - name of the tab
Returns:
the main component (generally a JPanel)

getTab

public java.awt.Component getTab(java.lang.String tabName)
Return the main component of a tab designated by its name

Parameters:
tabName - name of the tab
Returns:
the main component (generally a JPanel)

startBlink

public void startBlink(java.lang.String tabName)

stopBlink

public void stopBlink(java.lang.String tabName)

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
mouse pressed: define the origin when dragging

Specified by:
mousePressed in interface java.awt.event.MouseListener
Parameters:
e - mouseEvent object

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
mouse released:

Specified by:
mouseReleased in interface java.awt.event.MouseListener
Parameters:
e - mouseEvent object

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Mouse dragged. Follows the movement and manages the cursor between the tags

Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener
Parameters:
e - MouseEvent

isInTab

protected int isInTab(int x,
                      int y)
Checks if a coordinate is in a tab

Parameters:
x - X coordinate
y - Y coordinate
Returns:
the tab index if the (x,y) coordinate is in the tab, -1 otherwise

isInIcon

protected int isInIcon(int x,
                       int y)
Checks if a coordinate is in the Icon in a tab

Parameters:
x - X coordinate
y - Y coordinate
Returns:
the tab index if the (x,y) coordinate is in the Icon, -1 otherwise

moveTab

private void moveTab(int orig,
                     int dest)
Move a tab in the tabbedPane

Parameters:
orig - initial position of the tab to move
dest - final position of the tab

detachTab

private void detachTab(int n)
Detach the tab defined by its index

Parameters:
n - index in the tabbedPane of the tab to detach

attach_action

public void attach_action(java.awt.event.ActionEvent e)
Listener action method to re-attach the designated tab

Parameters:
e - Action Event

attach_action

public void attach_action(java.awt.event.WindowEvent e)
Listener action method to re-attach the designated tab, when clicking on the closing button of the window manager

Parameters:
e - Window Event object

attachFrame

private void attachFrame(javax.swing.JFrame frame)
Re-attach the content of a frame in its tabbedPane

Parameters:
frame - Frame object to re-attach

attachFrame

private void attachFrame(Tab t)
Re-attach the given tab

Parameters:
t - Tab object to reattach.

attach_all_action

public void attach_all_action()
Listener method to re-attach all frames coming from the same TabbedPane object than the one clicked


clean_desk

public static void clean_desk()
Listener method to reattach all the frames coming from all tabbed Panes


setActionCommand

public void setActionCommand(java.lang.String actionCommand)
Sets an action command name

Parameters:
actionCommand - the action command name

addActionListener

public void addActionListener(java.awt.event.ActionListener al)
Add an action listener to the listener list

Parameters:
al - the actionListener object that registers

removeActionListener

public void removeActionListener(java.awt.event.ActionListener al)
Remove an action listener from the listener list

Parameters:
al - the actionListener object that registers

fireEvent

public void fireEvent(int type,
                      int orig,
                      int dest)
Fire an event when moving a tab

Parameters:
type - type of event (CMotionEvent.MOVE, CMotionEvent.ATTACH, CMotionEvent.DETACH)
orig - initial position (MOVE, DETACH)
dest - final position (MOVE, ATTACH)