HOME

com.ultraswing
Class DockablePanel

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--com.ultraswing.DockablePanel
All Implemented Interfaces:
Accessible, EventListener, ImageObserver, MenuContainer, PropertyChangeListener, Serializable
Direct Known Subclasses:
AutoHideDockablePanel, SideBar

public class DockablePanel
extends JPanel
implements PropertyChangeListener

DockablePanel is a panel which is dockable and floatable. A DockablePanel only can dock on a CSplitPane container. A DockablePanel consists of a title bar and a content panel. For horizontal title, it's on the top of DockablePanel; and for vertical title, it's on the left of DockablePanel component. In both cases, content panel is in the center.

Usage example:

 CSplitPane split = new CSplitPane();
 DockablePanel dock = new DockablePanel(new JTextArea(), 
      "Dock 1 title", getImage("outline.gif"), false);
 //add dock to a CSplitPane container
 split.addPane(dock);
 

See Also:
Serialized Form

Field Summary
static int CLOSE_BUTTON
          This index for "close" button on the titlebar
static int DOCK_ANYWHERE
          no dock preference
static int DOCK_FIRST
          Prefer docking as the first component in split pane
static int DOCK_LAST
          Prefer docking as the last component in split pane
 
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
DockablePanel(Component comp, String title)
          Constructor
DockablePanel(Component comp, String title, boolean isVerticalTitle)
          Constructor
DockablePanel(Component comp, String title, Icon icon, boolean isVerticalTitle)
          Constructor
 
Method Summary
 void addDockingListener(ActionListener l)
          Adds a DockingEvent listener
 void addFocusListener(FocusListener l)
           
 void close()
          Closes this panel
 void doFloat(Point location, Dimension size)
          Floats this panel
 Component getComponent()
          Returns the component object of this panel
 int getDockPreference()
          Returns the dock preference
 Dimension getFloatingFrameSize()
          Gets the size of this panel when it's floating
 TitleBar getTitleBar()
          Returns the title bar object of this panel
 boolean isDockable()
          Tests whether this panel is dockable or not
 boolean isFloating()
          Tests if this panel is floating or not
protected  void processEvent(DockingEvent e)
          Processes events on this panel.
 void propertyChange(PropertyChangeEvent evt)
           
 void removeDockingListener(ActionListener l)
          Removes a DockingEvent listener
 void removeFocusListener(FocusListener l)
           
 boolean restore()
          Restores this panel to its previous state
 boolean restore(Point location, Dimension size)
          Restores this panel to its previous state
 void setDockable(boolean b)
          Sets this panel to be dockable or not
 void setDockPreference(int pref)
          Set docking preference when dock on JFrame
 void setFloatingFrameSize(Dimension dim)
          Sets the size of this panel when it's floating
 void setFrame(Frame frame)
          Sets the Frame object to be used when this panel is floating
 void setTitleBarColors(Color startingColorWhenFocused, Color endingColorWhenFocused, Color startingColorWhenNoFocus, Color endingColorWhenNoFocus)
          Sets title bar color
 void setToolTipText(int index, String tooltip)
          Sets tooltip for close button
 void setVisible(boolean b)
          Shows or hides this component depending on the value of parameter b.
 
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, 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, 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, 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

CLOSE_BUTTON

public static final int CLOSE_BUTTON
This index for "close" button on the titlebar

See Also:
Constant Field Values

DOCK_ANYWHERE

public static final int DOCK_ANYWHERE
no dock preference

See Also:
Constant Field Values

DOCK_FIRST

public static final int DOCK_FIRST
Prefer docking as the first component in split pane

See Also:
Constant Field Values

DOCK_LAST

public static final int DOCK_LAST
Prefer docking as the last component in split pane

See Also:
Constant Field Values
Constructor Detail

DockablePanel

public DockablePanel(Component comp,
                     String title)
Constructor

Parameters:
comp - the component which will be displayed at the center of this panel
title - title of this panel, displayed on the title bar

DockablePanel

public DockablePanel(Component comp,
                     String title,
                     boolean isVerticalTitle)
Constructor

Parameters:
comp - the component which will be displayed at the center of this panel
title - title of this panel, displayed on the title bar
isVerticalTitle - if true, show title bar vertically; otherwise, show title bar horizontally

DockablePanel

public DockablePanel(Component comp,
                     String title,
                     Icon icon,
                     boolean isVerticalTitle)
Constructor

Parameters:
comp - the component which will be displayed at the center of this panel
title - title of this panel, displayed on the title bar
icon - the small icon displayed at the left corner (horizotal case) or top corner (vertical case)
isVerticalTitle - if true, show title bar vertically; otherwise, show title bar horizontally
Method Detail

propertyChange

public void propertyChange(PropertyChangeEvent evt)
Specified by:
propertyChange in interface PropertyChangeListener

getComponent

public Component getComponent()
Returns the component object of this panel


getTitleBar

public TitleBar getTitleBar()
Returns the title bar object of this panel


setTitleBarColors

public void setTitleBarColors(Color startingColorWhenFocused,
                              Color endingColorWhenFocused,
                              Color startingColorWhenNoFocus,
                              Color endingColorWhenNoFocus)
Sets title bar color

Parameters:
startingColorWhenNoFocus - starting color of title bar when this panel has focus
endingColorWhenNoFocus - ending color of title bar when this panel has focus

setDockPreference

public void setDockPreference(int pref)
Set docking preference when dock on JFrame

Parameters:
pref - one of { DockablePanel.DOCK_FIRST, DockablePanel.DOCK_LAST, DockablePanel.DOCK_ANYWHERE}, DockablePanel.DOCK_ANYWHERE is the default value

getDockPreference

public int getDockPreference()
Returns the dock preference


setFloatingFrameSize

public void setFloatingFrameSize(Dimension dim)
Sets the size of this panel when it's floating


getFloatingFrameSize

public Dimension getFloatingFrameSize()
Gets the size of this panel when it's floating


isFloating

public boolean isFloating()
Tests if this panel is floating or not


setDockable

public void setDockable(boolean b)
Sets this panel to be dockable or not


isDockable

public boolean isDockable()
Tests whether this panel is dockable or not


close

public void close()
Closes this panel


restore

public boolean restore()
Restores this panel to its previous state

Returns:
false if nothing changed, true otherwise

restore

public boolean restore(Point location,
                       Dimension size)
Restores this panel to its previous state

Parameters:
location - the location of restored panel. Old value is used if the passed location is null
size - the size of restored panel. The old value is used if the passed size is null
Returns:
false if nothing changed, true otherwise

addFocusListener

public void addFocusListener(FocusListener l)
Overrides:
addFocusListener in class Component

removeFocusListener

public void removeFocusListener(FocusListener l)
Overrides:
removeFocusListener in class Component

setFrame

public void setFrame(Frame frame)
Sets the Frame object to be used when this panel is floating


doFloat

public void doFloat(Point location,
                    Dimension size)
Floats this panel

Parameters:
location - the location of the floating panel
size - this size of the floating panel

addDockingListener

public void addDockingListener(ActionListener l)
Adds a DockingEvent listener


removeDockingListener

public void removeDockingListener(ActionListener l)
Removes a DockingEvent listener


processEvent

protected void processEvent(DockingEvent e)
Processes events on this panel. Note that if the event parameter is null, nothing happens.

Parameters:
e - the event

setVisible

public void setVisible(boolean b)
Shows or hides this component depending on the value of parameter b.

Overrides:
setVisible in class JComponent
Parameters:
b - if true, shows this component; otherwise, hides this component

setToolTipText

public void setToolTipText(int index,
                           String tooltip)
Sets tooltip for close button

Parameters:
index - CLOSE_BUTTON : close button

HOME

Copyright © 2002 iReasoning Networks. All Rights Reserved.