JAPI 0_6-alpha-2
Yet another Java API
API Documentation

net.sf.japi.swing
Class ToolBarLayout

java.lang.Object
  extended by java.awt.BorderLayout
      extended by net.sf.japi.swing.ToolBarLayout
All Implemented Interfaces:
LayoutManager, LayoutManager2, Serializable

public class ToolBarLayout
extends BorderLayout

A LayoutManager that manages a layout of a Container similar to BorderLayout but with an important difference, it is possible to add as many components to a side layout region as you want. The desired purpose is to serve as LayoutManager for containers that shall contain toolbars. So this is a LayoutManager you always were looking for.

Technically, this class is not a 100% replacement for BorderLayout. JToolBar's UI (BasicToolBarUI) directly looks for some features of the class BorderLayout, and if it is not BorderLayout, it uses some defaults. This class has been developed to make these defaults work as good as possible. Though this class doesn't technically replace BorderLayout - neither is this class a subclass of BorderLayout nor does it provide all methods BorderLayout does - it still does practically.

The constant values BorderLayout.NORTH, BorderLayout.SOUTH, BorderLayout.EAST, BorderLayout.WEST and BorderLayout.CENTER are references to those of BorderLayout. The behaviour of BorderLayout.CENTER is that of BorderLayout: only one component can be added, subsequently added components overried all previously added.

The behaviour of BorderLayout.NORTH, BorderLayout.SOUTH, BorderLayout.EAST and BorderLayout.WEST differs from BorderLayout. The position and layout behaviour is the same, with the slight difference that this LayoutManager is able to manage more than on single component in these four regions. Subsequently added components are placed from the outer to the inner. The first added component is the outmost component of that region, the last added component is the innermost component of that region. To place a component to the innermost level, simply add it to the same region again.

Placing a component another level than the innermost of its destination region is currently not supported but might well be supported in future.

There are four possible ways of specifying a constraint:

. The constraint may be one of the String constants from this class or BorderLayout or it may be a ToolBarLayout.ToolBarConstraints.

Version:
$Id: ToolBarLayout.java,v 1.2 2006/02/09 23:58:22 christianhujer Exp $
Author:
$Author: christianhujer $
See Also:
BorderLayout, JToolBar, Serialized Form
Todo:
support rtl containers the same way as BorderLayout does it., test ToolBarLayout.ToolBarConstraints and ToolBarLayout.ToolBarConstraints.Region

Nested Class Summary
static class ToolBarLayout.ToolBarConstraints
          Class for ToolBarLayout constraints.
 
Field Summary
 
Fields inherited from class java.awt.BorderLayout
AFTER_LAST_LINE, AFTER_LINE_ENDS, BEFORE_FIRST_LINE, BEFORE_LINE_BEGINS, CENTER, EAST, LINE_END, LINE_START, NORTH, PAGE_END, PAGE_START, SOUTH, WEST
 
Constructor Summary
ToolBarLayout()
          Create a ToolBarLayout with zero gaps.
ToolBarLayout(int hgap, int vgap)
          Create a TooLBarLayout.
 
Method Summary
 void addLayoutComponent(Component comp, Object constraints)
          
 void addLayoutComponent(String name, Component comp)
          
 float getLayoutAlignmentX(Container parent)
          
 float getLayoutAlignmentY(Container parent)
          
 void invalidateLayout(Container target)
          
 void layoutContainer(Container target)
          
 Dimension maximumLayoutSize(Container target)
          
 Dimension minimumLayoutSize(Container target)
          
 Dimension preferredLayoutSize(Container target)
          
 void removeLayoutComponent(Component comp)
          
 String toString()
          
 
Methods inherited from class java.awt.BorderLayout
getConstraints, getHgap, getLayoutComponent, getLayoutComponent, getVgap, setHgap, setVgap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ToolBarLayout

public ToolBarLayout()
Create a ToolBarLayout with zero gaps.


ToolBarLayout

public ToolBarLayout(int hgap,
                     int vgap)
Create a TooLBarLayout.

Parameters:
hgap - horizontal gap between components
vgap - vertical gap between components
Method Detail

addLayoutComponent

public void addLayoutComponent(String name,
                               Component comp)

Specified by:
addLayoutComponent in interface LayoutManager
Overrides:
addLayoutComponent in class BorderLayout

addLayoutComponent

public void addLayoutComponent(Component comp,
                               Object constraints)

Specified by:
addLayoutComponent in interface LayoutManager2
Overrides:
addLayoutComponent in class BorderLayout

getLayoutAlignmentX

public float getLayoutAlignmentX(Container parent)

Specified by:
getLayoutAlignmentX in interface LayoutManager2
Overrides:
getLayoutAlignmentX in class BorderLayout

getLayoutAlignmentY

public float getLayoutAlignmentY(Container parent)

Specified by:
getLayoutAlignmentY in interface LayoutManager2
Overrides:
getLayoutAlignmentY in class BorderLayout

invalidateLayout

public void invalidateLayout(Container target)

Specified by:
invalidateLayout in interface LayoutManager2
Overrides:
invalidateLayout in class BorderLayout

layoutContainer

public void layoutContainer(Container target)

Specified by:
layoutContainer in interface LayoutManager
Overrides:
layoutContainer in class BorderLayout

maximumLayoutSize

public Dimension maximumLayoutSize(Container target)

Specified by:
maximumLayoutSize in interface LayoutManager2
Overrides:
maximumLayoutSize in class BorderLayout

minimumLayoutSize

public Dimension minimumLayoutSize(Container target)

Specified by:
minimumLayoutSize in interface LayoutManager
Overrides:
minimumLayoutSize in class BorderLayout

preferredLayoutSize

public Dimension preferredLayoutSize(Container target)

Specified by:
preferredLayoutSize in interface LayoutManager
Overrides:
preferredLayoutSize in class BorderLayout

removeLayoutComponent

public void removeLayoutComponent(Component comp)

Specified by:
removeLayoutComponent in interface LayoutManager
Overrides:
removeLayoutComponent in class BorderLayout

toString

public String toString()

Overrides:
toString in class BorderLayout

JAPI
Yet another Java API
API Documentation

© 2005-2006 Christian Hujer. All rights reserved. See copyright