dsx.JDockFloatPro
Class DockFloatWindow

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--dsx.JDockFloatPro.DockFloatWindow
Direct Known Subclasses:
DockFloatToolMenuBar
DockFloatPanel

public class DockFloatWindow
extends javax.swing.JPanel

An extended version of javax.swing.JPanel that can be dockable and floatable.     You can use the method add(java.awt.Component com, Object constraint) to add any component to DockFloatWindow and make it dockable and floatable.   The DockFloatWindow can be only docked to either an object of  DockFloatFrame. or DockFloatPanel  The following is the sample code of how to use DockFloatWindow.    You can also use the method setInitialLayoutReference to dynamically configure the layout.
            
  // suppose that dfframe is an instance of DockFloatFrame
  dsx.JDockFloatPro.DockFloatWindow dfwindow=            
          
    
            new dsx.JDockFloatPro.DockFloatWindow(dfframe,"Debug Window"); 
  dfwindow.setSize(200,200); 
  dfwindow.add(newJTextArea(),BorderLayout.CENTER); // add a JTextArea component
  dfwindow.initStates(dfwindow.DOCKTOP); //dock to top side of dfframe
  
See Also:
 

Inner classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Field Summary
static int AUTOSIDE 
           
static int BOTTOMSIDE 
           
static int DOCKBOTTOM 
           
static int DOCKBOTTOMMASK
           
static int DOCKLEFT
           
static int DOCKLEFTMASK 
           
static int DOCKRIGHT 
           
static int DOCKRIGHTMASK
           
static int DOCKTOP 
           
static int DOCKTOPMASK  
           
static int FLOAT  
           
static int LEFTSIDE 
           
static int MOUSECLICKPOPUP 
           
static int MOUSEMOVEPOPUP 
           
static int NOPIN 
           
static int PINNNED 
           
static int RIGHTSIDE 
           
static int TOPSIDE 
           
static int UNPINNED 
           
 
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
 
Constructor Summary
DockFloatWindow(DockFloatFrame pframe, java.lang.String sTitle)
DockFloatWindow(DockFloatPanel ppanel, java.lang.String sTitle)
           
 
Method Summary
java.awt.component add(java.lang.String s,java.awt.component) 
           
void add(java.awt.component,java.lang.Object constratint) 
           
     int dockIt()
           
 int floaIt()
           
 Font getCaptionFont()
           
 int getCaptionHW()
           
int getDockSide()
           
 int getDockableMask()
           
 int getDragSide()
           
   boolean getFloatable() 
           
   boolean getFloatInSingle() 
           
   int getInvokeUnpinAction() 
           
   java.lang.String getPersistToken() 
           
protected  Dimension getPreferredSize(int iDockSide)
           
 java.lang.String getTitle()
           
   int getUnpinnedLocation() 
           
 void initStates(int dwDockSide)
           
protected  boolean hasHiddenArea()
           
 void setCaptionFont(Font fontCaption)
           
 void setCaptionHW(int iCaptionHW)
           
 void setDockableMask(int iMask)
           
 void setDragSide(int iDragSide)
           
 void setFloatable(boolean bFloatable)
           
 void setFloatInSingle(boolean bInSingle)
           
   void setImage(Image img) 
           
   void setInitialLayoutReference(DockFloatWindow dwRefWindow) 
           
   void setInvokeUnpinAction(int iAction) 
           
 void setPersistToken(java.lang.String sToken)
           
   void setPinStyle(int iPinStyle) 
           
 void setTitle(java.lang.String sTitle)
           
   void setVisible(boolean bShow) 
           
   void setUnpinnedLocation(int iUnpinnedLocation) 
           
void setSize(int iWidth,int iHeight) 
           
  void setSize(java.awt.Dimension d) 
           
  void unload(boolean bSaveStates ) 
           
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUIClassID, paramString, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInsets, getInsets, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, processComponentKeyEvent, processFocusEvent, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hide, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setLocation, setName, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

AUTOSIDE

public static final int AUTOSIDE
Constant used for the method setUnpinnedLocation(), getUnpinnedLocation(),setDragSide and getDragSide .      AUTOSIDE specifies that a unpinned DockFloatWindow can be located on the left, top, right and bottom of the dockable container. If a DockFloatWindow is docked to either DockFloatFrame or DockFloatPanel, the unpinned location is in the side where the componet is docked. If a DockFloatWindow is in the floated state, the unpinned location will always be in the left side of  either DockFloatFrame or DockFloatPanel.

BOTTOMSIDE

public static final int BOTTOMSIDE
Constant used for the methodsetUnpinnedLocation(), getUnpinnedLocation(),setDragSide and getDragSide.      BOTTOMSIDE specifies that a unpinned DockFloatWindow is located in the bottom side of the dockable container.

DOCKLEFT

public static final int DOCKLEFT
Constant used for method initStates() and getDockSide().      DOCKLEFT specifies that Dock/Float window is docked to left.

DOCKLEFTMASK

public static final int DOCKLEFTMSSK
Constant used for method setDockableMask() and getDockableMask().     DOCKLEFTMASK makes Dock/Float window dockable to left.

DOCKTOP

public static final int DOCKTOP
Constant used for method initStates() and getDockSide().     DOCKTOP specifies that Dock/Float window is docked to top.

DOCKTOPMASK

public static final int DOCKTOPMASK
Constant used for method setDockableMask()and getDockableMask().     DOCKTOPMASK makes Dock/Float window dockable to top.

DOCKRIGHT

public static final int DOCKRIGHT
Constant used for method initStates() and getDockSide().    DOCKRIGHT specifies that Dock/Float window is docked to right.

DOCKRIGHTMASK

public static final int DOCKRIGHTMASK
Constant used for method setDockableMask() and getDockableMask().     DOCKRIGHTMASK makes Dock/Float window dockable to right.

DOCKBOTTOM

public static final int DOCKBOTTOM
Constant used for method initStates() and getDockSide().    DOCKBOTTOM specifies that Dock/Float window is docked to bottom.

DOCKBOTTOMMASK

public static final int DOCKBOTTOMMASK
Constant used for method setDockableMask() and getDockableMask().    DOCKBOTTOMMASK makes Dock/Float window dockable to bottom.

FLOAT

public static final int FLOAT
Constant used for method getDockSide()and initStates()

LEFTSIDE

public static final int LEFTSIDE
Constant used for the method setUnpinnedLocation(), getUnpinnedLocation(),setDragSide and getDragSide.      LEFTSIDE specifies that a unpinned DockFloatWindow is located in the left side of the dockable container.

MOUSECLICKPOPUP

public static final int MOUSECLICKPOPUP
Constant used for the method setInvokeUnpinAction() and getInvokeUnpinAction().      MOUSECLICKPOPUP specifies that a unpinned DockFloatWindow is automatically switched to pinned position when left mouse click is on the unpinned location.

MOUSEMOVEPOPUP

public static final int MOUSEMOVEPOPUP
Constant used for the method setInvokeUnpinAction() and getInvokeUnpinAction().      MOUSEMOVEPOPUP specifies that  DockFloatWindow is automatically shown if mouse is moved over the unpinned location.

NOPIN

public static final int NOPIN
Constant used for the method setPinStyle() and getPinStyle().      NOPIN specifies that a DockFloatWindow has no pin.

PINNED

public static final int PINNED
Constant used for the method setPinStyle() and getPinStyle().      PINNED specifies that a DockFloatWindow is in the pinned state.

RIGHTSIDE

public static final int RIGHTSIDE
Constant used for the method setUnpinnedLocation(), getUnpinnedLocation(),setDragSide and getDragSide.      RIGHTSIDE specifies that a unpinned DockFloatWindow is located in the right side of the dockable container.

TOPSIDE

public static final int TOIPSIDE
Constant used for the method setUnpinnedLocation(), getUnpinnedLocation(),setDragSide and getDragSide.      TOPSIDE specifies that a unpinned DockFloatWindow is located in the top side of the dockable container.

UNPINNED

public static final int UNPINNED
Constant used for the method setPinStyle() and getPinStyle().      UNPINNED specifies that a DockFloatWindow is in the unpinned state.

Constructor Detail

DockFloatWindow

public DockFloatWindow(DockFloatFrame pframe,
                       java.lang.String sTitle)
Parameters
pframe - an instance of DockFloatFrame which can be used as the container for docking .  If docked,  DockFloatWindow can only be docked to pframe.  If floated, DockFloatWindow is always on the top of the pframe and can be floated anywhere in the screen.
sTitle -  a string for the title.
public DockFloatWindow(DockFloatPanel pPanel,
                       java.lang.String sTitle)
Parameters
pPanel - an instance of DockFloatPanel which can be used as the container for docking .  If docked,  DockFloatWindow can only be docked to pPanel.  If floated, DockFloatWindow is always on the top of the pPanel and can be floated anywhere inside the pPanel.  In most of cases, you don't need to use this constructor to create DockFloatWindow.    Please see the DockFloatPanel for details on how to use DockFloatPanel and check our demo PanelDemo. 
Method Detail

add

public java.awt.Component add(java.lang.String s,java.awt.Component com)
Adds the specified component to the end of this container. The specified component is put at the center of this container.
Returns
the component argument.
Parameters
s - this parmeter is ignored
com - the component to be added
Overrides
add in class Container.

add

public void add(java.awt.Component com,java.lang.Object constraints)
Adds the specified component to the end of this container. The specified component is put at the center of this container
Parameters
com - the component to be added
constraints - this parameter is ignored
Overrides
add in class Container.

dockIt

public void dockIt()
Docks the Dock/Float window if it is visible and currently in float state. This function will do nothing if the component is invisible or already in float state.

floatIt

public void floatIt()
Floats the Dock/Float window if it is visible and currently in dock state.   This function will do nothing if the component is invisible or already in docked state.

getDockSide

public int getDockSide()
Gets current Dock/Float states
Returns
a integer value specifying the Dock/Float states, its valid value are
DOCKLEFT
DOCKTOP
DOCKBOTTOM
DOCKRIGHT

setFloatable

public void setFloatable(boolean  bfloatable)
Sets the value specifying if the component can be floatable.  
Parameters
bfloatable - a boolean value.   If true, the component can be floatable, otherwise, the component cann't be floatable.    

getFloatable

public boolean getFloatable()
Returns whether this Component can be floatable

setPersistToken

public void setPersistToken(java.lang.String sToken)
Sets the string for loading/saving the dock/float states of this component.   If the function is not called,  the title of the component is used for loading/saving the dock/float states.  Please set sToken unique for each DockFloatWindow.
Parameters
sToken - a string for the token. 

getPersistToken

public java.lang.String getPersistToken()
Gets the persist token for this component.

setTitle

public void setTitle(java.lang.String sTitle)
Sets the title of the Dock/Float window. The title is shown as the caption of the DockFloatWindow.   It is also used for loading and saving the Dock/Float states if the method setPersistToken is not called.
Parameters
sTitle - a string for the title. 

getTitle

public java.lang.String getTitle()
Gets the title of the Dock/Float window

setUnpinnedLocation

public void setUnpinnedLocation(int  iLocation)
Sets the title of the Dock/Float window. The title is shown as the caption of the DockFloatWindow.   It is also used for loading and saving the Dock/Float states if the method setPersistToken is not called.
Parameters
iLocation - a integer value which can be one of the following values
LEFTSIDE
TOPSIDE
RIGHTSIDE
BOTTOMSIDE
AUTOSIDE

getUnpinnedLocation

public java.lang.String getUnpinnedLocation()
Gets the unpinned location of the compoent 

setPinStyle

public void setPinStyle(int  iPinStyle)
Sets the pin style of the DockFloatWindow. The title is shown as the caption of the DockFloatWindow.   It is also used for loading and saving the Dock/Float states if the method setPersistToken is not called.
Parameters
iPinStyle - a integer value which can be one of the following values
PINNED
UNPINNED
NOPIN

getPinStyle

public int getPinStyle()
Gets the title of the Dock/Float window

setInvokeUnpinAction

public void setInvokeUnpinAction(int  iAction)
Sets the title of the Dock/Float window. The title is shown as the caption of the DockFloatWindow.   It is also used for loading and saving the Dock/Float states if the method setPersistToken is not called.
Parameters
iAction - a integer value which can be one of the following values
MOUSEMOVEPOPUP
MOUSECLICKPOPUP

getInvokeUnpinAction

public int getInvokeUnpinAction()
Gets the title of the Dock/Float window

setDragSide

public void setDragSide(int iDragSide)
Sets the location of the drag area 
Parameters
iDragSide - a integer value which is one of the following constants
AUTOSIDE
BOTTOMSIDE
LEFTSIDE
RIGHTSIDE
TOPSIDE

getDragSide

public int getDragSide()
Gets the location of the drag area
Returns
a integer value which can be one of the following constants
AUTOSIDE
BOTTOMSIDE
LEFTSIDE
RIGHTSIDE
TOPSIDE

setDockableMask

public void setDockableMask(int iMask)
Sets the mask for dockable sides
Parameters
iMask - a integer value which is the combination of following constants
DOCKLEFTMASK
DOCKTOPMASK
DOCKBOTTOMMASK
DOCKRIGHTMASK

getDockableMask

public int getDockableMask()
Gets the mask fo dockable sides
Returns
a integer value specifying the mask for dockable sides, it can be combinations of following constants
DOCKLEFTMASK
DOCKTOPMASK
DOCKBOTTOMMASK
DOCKRIGHTMASK

setCaptionHW

public void setCaptionHW(int iCaptionHW)
Sets the either height or width of the caption area.  If caption area is in LEFTSIDE, RIGHTSIDE, the value is the width of the caption;  if caption is in TOPSIDE, BOTTOMSIDE, the value is the height of the caption. 
Parameters
iCaptionHW - an integer specifying either height or width.

getCaptionHW

public int getCaptionHW()
Gets the either width or height of the caption area.
Parameters
None.

setCaptionFont

public void setCaptionFont(Font fontCaption)
Sets the font used to draw the caption text.
Parameters
fontCaption - an instance of  Font.

getCaptionFont

public Font getCaptionFont()
Gets the font used to draw the caption text.
Parameters
None.

setFloatInSingle

public void setFloatInSingle(boolean bFloatInSingle)
Sets the value specifying if the control can be docked to floated frames.   If bFloatInSignel is false,  the  control can be docked to the floated frames, otherwise the control can not docked to the floated frames.
Parameters
bFloatInSingle - a boolean value.

getFloatInSingle

public boolean getFloatInSingle()
Gets the value specifying if the control can be docked to the floated frames.
Parameters
None.

setImage

public void setImage(java.awt.Image img)
Sets the image which is shown when the DockFloatWindow is either tabbed or unpinned.
Parameters
img - an instance of java.awt.Image.

getImage

public java.awt.Image getImage()
Gets the image of the DockFloatWindow.
Parameters
None.

setInitialLayoutReference

public void setInitalLayoutReference(DockFloatWindow dwRef)
Sets the layout relation between two DockFloatWindow objects.   The relation is used for layout if LoadDockFloatStates is not called or ClearLayout is called..   This function together with setSize, setVisible, setPintStyle, setLocationinitStates ,provide users to dynamically layout the DockFloatWindow.  If dwOne is null,  the DockFloatWindow setups the layout without using any existing DockFloatWindow as a reference.   The following examples show how to use the method setInitialLayoutReference.    The dwOne is loaded first .
  
DockFloatFrame dframe = new DockFloatFrame();
DockFloatWindow dwOne = new DockFloatWindow(dframe, "dfOne");
DockFloatWindow dwTwo = new DockFloatWindow(dframe, "dfTwo");
// we omit the codes for adding tree controls to dfOne.
// we omit the codes for adding buttons and text box to dfTwo.
dwOne.setSize(150,170); 
dwOne.setVisible(true);
dwOne.setPinStyle(DockFloatWindow.PINNED);
dwOne.initStates(DockFloatWindow.DOCKTOP); 
After dwOne is loaded, the layout is as shown below
     
     
dwTwo is loaded using dwOne as the reference.   The following table shows some samples of different layouts      
         
		
		
		
		
 
 	dwTwo.setSize(140,100);
	dwTwo.setVisible(true);
	dwTow.setInitialLayoutReference(dwOne);
	dwTwo.initStates(DockFloatWindow.DOCKLEFT);

 

 

 

 

dfTwo.setSize(170,70);
dfTwo.setInitialLayoutReference(dwOne);
dfTwo.setVisible(true);
dfTwo.initStates(DockFloatWindow.DOCKTOP);

 

 

 

 

dfTwo.setSize(90,90);
dfTwo.setLayoutReference(dwOne);
dfTwo.setVisible(true);
dfTwo.initStates(DockFloatWindow.DOCKRIGHT);

 

 

 

 

 

dfTwo.SetInitialLayoutReference(dfOne);
dfTwo.setSize(70,70);
dfTwo.setVisible(true);
dfTwo.initStates(DockFloatWindow.DOCKBOTTOM);

 

 

 

 

 

 

dfTwo.SetInitialLayoutReference(dfOne);
dfTwo.setVisible(true);
dfTwo.initStates(DockFloatWindow.FLOAT);

 

 

 

 

As you see in the above,  SetInitialLayoutReference provides you to set any layout you want.   If you change the location of the dwOne,  you will get different layouts.    Our example LayoutDemo.java shows you how to setup different layouts in run time.   Please check our demo source codes for details.
 
Parameters
dwRef - an instance of DockFloatWindow used for the reference 

setSize

public void setSize(int iWidth,int iHeight)
Sets the initial size of the Dock/Float window. The function will call JComponent's method setSize(int, int) if the method initStates() is not called, otherwise this method does nothing.
Parameters
iWidth - specifies the width.    It is only used if initial state is floating or docked to left or docked to right.
iHeight - specifies the height    It is only used if initial state is floating or docket to top or docked to bottom.
Overrides:
setSize in class javax.swing.JComponent

setSize

public void setSize(java.awt.Dimension d)
Sets the initial size of the Dock/Float window. The function will call JComponent's method setSize(Dimension) if the method initStates() is not called, otherwise this method does nothing.
Parameters
d - specifies the dimension
Overrides:
setSize in class javax.swing.JComponent

setVisible

public void setVisible(boolean bShow)
Show or hide the Dock/Float window
Parameters
bShow - specifies if visible. if true it is visible, otherwise is invisible
Overrides:
setVisible in class javax.swing.JComponent

hasHiddenArea

protected boolean hasHiddenArea()
Returns
Specifies if the Dock/Float window has a hidden area. If returns true, the window has a area that user can click to hide the window, otherwise no area is provided.  

initStates

public void initStates(int iDockSide)
Sets the initial state of the Dock/Float window. If LoadDockFloatStates is called before calling initStates(), the previous Dock/Float state is restored, otherwise iDockSide will be used to initalize the state.
Parameters
iDockSide - Specifies the initial state. It can be one of the following values
DOCKLEFT
DOCKTOP
DOCKBOTTOM
DOCKRIGHT

unload

public void unload(boolean bSaveStates)
Unload the DockFloatWindow from the memory
Parameters
bSaveStates - Specifies if the dock/float states is to be saved.  If true, the compoent's dock/float states will be saved, otherwise the dock/float states will be lost.