uic.widgets
Class ToolBarContainer

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended byuic.widgets.ToolBarContainer
All Implemented Interfaces:
Accessible, ImageObserver, MenuContainer, Serializable

public class ToolBarContainer
extends JPanel

This ToolBarContainer is a Container that allows a number of Toolbars to be present at a certain side of the screen. The Swing Tutorials describe ways to add only one Toolbar per side of the screen, and its quite hard to actually add a toolbar correctly, this class is suppost to make it easy. The simplest way of using the container is like this:

 JFrame myFrame = new JFrame();
 ToolBarContainer top = new ToolBarContainer(myFrame, SwingConstants.TOP);
 JToolBar fileTools = new JToolBar("File");
     // add some buttons to the fileTools toolbar.
 top.add(fileTools); 
Note that at any time you can still add another toolbar to the container:

 JToolBar projectTools = new JToolBar("Project");
     // add some buttons to the projectTools toolbar.
 top.add(projectTools); 

Known issue: due to the nature of Toolbars in Swing the usage of this container stops a toolbar being able to be 'dragged' from one side of the window to another if you do not use the accompanied UICTheme in your application.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 
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
ToolBarContainer()
          It is legal; but not advisable to create a ToolBarContainer by yourself, use the placeToolBarOnWindow factory method instead.
ToolBarContainer(int placing)
          It is legal; but not advisable to create a ToolBarContainer by yourself, use the placeToolBarOnWindow factory method instead.
ToolBarContainer(Window parent, int placing)
          It is legal; but not advisable to create a ToolBarContainer by yourself, use the placeToolBarOnWindow factory method instead.
 
Method Summary
 Component add(Component child)
          Overloaded method, look at Container
 Component add(Component child, int index)
          Overloaded method, look at Container
 void add(Component child, Object contraints)
          Overloaded method, look at Container
 boolean canDrop(Point screenCoordinate, boolean paintDropLocation)
          find out if a toolbar at screenCoordinate is 'over' us and the user intends to drop it on us.
protected  JToolBar createToolBar(Component widget, String name)
          rotate and/or wrap the widget in a toolbar (if not a toolbar allready)
 Dimension getMinimumSize()
          Make it always 1 pixel width and hight.
 int getPlacing()
          Each ToolBarLayouter is placed on a Window-edge.
 Dimension getPreferredSize()
          Work around bug that borderlayout does not honor minimumSize.
 boolean isHorizontal()
          Shorthand 'orientation' method.
 void paint(Graphics g)
          Draw seperators.
static JToolBar placeToolBarOnWindow(Container widget, MainWindow window)
          Add a toolbar to the mainwindow
static JToolBar placeToolBarOnWindow(Container widget, MainWindow window, int placing)
          Add a toolbar to the mainwindow
static JToolBar placeToolBarOnWindow(Container widget, MainWindow window, String name)
          Add a toolbar to the mainwindow
static JToolBar placeToolBarOnWindow(Container widget, MainWindow window, String name, int placing)
           
static JToolBar placeToolBarOnWindow(Container widget, Window window)
           
static JToolBar placeToolBarOnWindow(Container widget, Window window, int placing)
           
static JToolBar placeToolBarOnWindow(Container widget, Window window, String name)
           
static JToolBar placeToolBarOnWindow(Container widget, Window window, String name, int placing)
          builder method to put a toolbar on a Window; note that both JFrame and JDialog are Windows.
 
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, getNextFocusableComponent, 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, 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, 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
 

Constructor Detail

ToolBarContainer

public ToolBarContainer()
It is legal; but not advisable to create a ToolBarContainer by yourself, use the placeToolBarOnWindow factory method instead.


ToolBarContainer

public ToolBarContainer(int placing)
It is legal; but not advisable to create a ToolBarContainer by yourself, use the placeToolBarOnWindow factory method instead.

Parameters:
placing - from the box-tyoe SwingConstants (top/bottom etc).

ToolBarContainer

public ToolBarContainer(Window parent,
                        int placing)
It is legal; but not advisable to create a ToolBarContainer by yourself, use the placeToolBarOnWindow factory method instead.

Parameters:
placing - from the box-tyoe SwingConstants (top/bottom etc).
parent - the containing window where the container should be added to.
Method Detail

add

public Component add(Component child)
Overloaded method, look at Container


add

public Component add(Component child,
                     int index)
Overloaded method, look at Container


add

public void add(Component child,
                Object contraints)
Overloaded method, look at Container


isHorizontal

public boolean isHorizontal()
Shorthand 'orientation' method.


getPlacing

public int getPlacing()
Each ToolBarLayouter is placed on a Window-edge.

Returns:
the side of the window from the SwingConstants LEFT/RIGHT/TOP/BOTTOM

createToolBar

protected JToolBar createToolBar(Component widget,
                                 String name)
rotate and/or wrap the widget in a toolbar (if not a toolbar allready)


paint

public void paint(Graphics g)
Draw seperators. (overloaded method)


canDrop

public boolean canDrop(Point screenCoordinate,
                       boolean paintDropLocation)
find out if a toolbar at screenCoordinate is 'over' us and the user intends to drop it on us.

Parameters:
screenCoordinate - the point where the users-pointer is
paintDropLocation - if true will give graphical feedback on where exactly the toolbar will be dropped

placeToolBarOnWindow

public static JToolBar placeToolBarOnWindow(Container widget,
                                            Window window,
                                            String name)

placeToolBarOnWindow

public static JToolBar placeToolBarOnWindow(Container widget,
                                            Window window,
                                            int placing)

placeToolBarOnWindow

public static JToolBar placeToolBarOnWindow(Container widget,
                                            Window window)

placeToolBarOnWindow

public static JToolBar placeToolBarOnWindow(Container widget,
                                            MainWindow window,
                                            String name)
Add a toolbar to the mainwindow

Since:
1.2

placeToolBarOnWindow

public static JToolBar placeToolBarOnWindow(Container widget,
                                            MainWindow window,
                                            int placing)
Add a toolbar to the mainwindow

Since:
1.2

placeToolBarOnWindow

public static JToolBar placeToolBarOnWindow(Container widget,
                                            MainWindow window)
Add a toolbar to the mainwindow

Since:
1.2

placeToolBarOnWindow

public static JToolBar placeToolBarOnWindow(Container widget,
                                            MainWindow window,
                                            String name,
                                            int placing)

placeToolBarOnWindow

public static JToolBar placeToolBarOnWindow(Container widget,
                                            Window window,
                                            String name,
                                            int placing)
builder method to put a toolbar on a Window; note that both JFrame and JDialog are Windows.

Parameters:
widget - the widget you want to place as a toolbar on the window; can be a toolbar but also a simple widget that will then be placed in a toolbar.
window - the target Window
name - of the toolbar.
placing - a direction from the UICToolBar on where the toolbar is to be placed. One of LEFT/RIGHT/TOP/BOTTOM/FLAT/FLOATING/HIDDEN.
Throws:
IllegalArgumentException - when placing is an illegal value, or window is null.

getMinimumSize

public Dimension getMinimumSize()
Make it always 1 pixel width and hight. Not realy needed when using the UIC Theme, but for others its needed.


getPreferredSize

public Dimension getPreferredSize()
Work around bug that borderlayout does not honor minimumSize. Return preferred size that is never smaller then the minimumSize.



Copyright © 2002,2003 Thomas Zander Available under the Free Apache licence