|
JAPI 0.9.0 Yet another Java API API Documentation |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.BorderLayout net.sf.japi.swing.ToolBarLayout
public class ToolBarLayout
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.
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:
BorderLayout
ToolBarLayout.ToolBarConstraints
ToolBarLayout.ToolBarConstraints.Region
BorderLayout
or it may
be a ToolBarLayout.ToolBarConstraints
.
BorderLayout
,
JToolBar
,
Serialized FormBorderLayout
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)
Adds the specified component to the layout, using the specified constraint object. |
void |
addLayoutComponent(String name,
Component comp)
If the layout manager uses a per-component string, adds the component comp to the layout,
associating it
with the string specified by name . |
float |
getLayoutAlignmentX(Container parent)
Returns the alignment along the x axis. |
float |
getLayoutAlignmentY(Container parent)
Returns the alignment along the y axis. |
void |
invalidateLayout(Container target)
Invalidates the layout, indicating that if the layout manager has cached information it should be discarded. |
void |
layoutContainer(Container target)
Lays out the container argument using this border layout. |
Dimension |
maximumLayoutSize(Container target)
Returns the maximum dimensions for this layout given the components in the specified target container. |
Dimension |
minimumLayoutSize(Container target)
Determines the minimum size of the target container
using this layout manager. |
Dimension |
preferredLayoutSize(Container target)
Determines the preferred size of the target
container using this layout manager, based on the components
in the container. |
void |
removeLayoutComponent(Component comp)
Removes the specified component from this border layout. |
String |
toString()
Returns a string representation of the state of this border layout. |
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 |
---|
public ToolBarLayout()
public ToolBarLayout(int hgap, int vgap)
hgap
- horizontal gap between componentsvgap
- vertical gap between componentsMethod Detail |
---|
public void addLayoutComponent(String name, Component comp)
comp
to the layout,
associating it
with the string specified by name
.
addLayoutComponent
in interface LayoutManager
addLayoutComponent
in class BorderLayout
name
- the string to be associated with the componentcomp
- the component to be addedpublic void addLayoutComponent(Component comp, Object constraints)
NORTH
,
SOUTH
, EAST
,
WEST
, or CENTER
.
Most applications do not call this method directly. This method
is called when a component is added to a container using the
Container.add
method with the same argument types.
addLayoutComponent
in interface LayoutManager2
addLayoutComponent
in class BorderLayout
comp
- the component to be added.constraints
- an object that specifies how and where
the component is added to the layout.Container.add(java.awt.Component, java.lang.Object)
public float getLayoutAlignmentX(Container parent)
getLayoutAlignmentX
in interface LayoutManager2
getLayoutAlignmentX
in class BorderLayout
public float getLayoutAlignmentY(Container parent)
getLayoutAlignmentY
in interface LayoutManager2
getLayoutAlignmentY
in class BorderLayout
public void invalidateLayout(Container target)
invalidateLayout
in interface LayoutManager2
invalidateLayout
in class BorderLayout
public void layoutContainer(Container target)
This method actually reshapes the components in the specified
container in order to satisfy the constraints of this
BorderLayout
object. The NORTH
and SOUTH
components, if any, are placed at
the top and bottom of the container, respectively. The
WEST
and EAST
components are
then placed on the left and right, respectively. Finally,
the CENTER
object is placed in any remaining
space in the middle.
Most applications do not call this method directly. This method
is called when a container calls its doLayout
method.
layoutContainer
in interface LayoutManager
layoutContainer
in class BorderLayout
target
- the container in which to do the layout.Container
,
Container.doLayout()
public Dimension maximumLayoutSize(Container target)
maximumLayoutSize
in interface LayoutManager2
maximumLayoutSize
in class BorderLayout
target
- the component which needs to be laid outContainer
,
BorderLayout.minimumLayoutSize(java.awt.Container)
,
BorderLayout.preferredLayoutSize(java.awt.Container)
public Dimension minimumLayoutSize(Container target)
target
container
using this layout manager.
This method is called when a container calls its
getMinimumSize
method. Most applications do not call
this method directly.
minimumLayoutSize
in interface LayoutManager
minimumLayoutSize
in class BorderLayout
target
- the container in which to do the layout.
Container
,
BorderLayout.preferredLayoutSize(java.awt.Container)
,
Container.getMinimumSize()
public Dimension preferredLayoutSize(Container target)
target
container using this layout manager, based on the components
in the container.
Most applications do not call this method directly. This method
is called when a container calls its getPreferredSize
method.
preferredLayoutSize
in interface LayoutManager
preferredLayoutSize
in class BorderLayout
target
- the container in which to do the layout.
Container
,
BorderLayout.minimumLayoutSize(java.awt.Container)
,
Container.getPreferredSize()
public void removeLayoutComponent(Component comp)
remove
or
removeAll
methods. Most applications do not call this
method directly.
removeLayoutComponent
in interface LayoutManager
removeLayoutComponent
in class BorderLayout
comp
- the component to be removed.Container.remove(java.awt.Component)
,
Container.removeAll()
public String toString()
toString
in class BorderLayout
|
JAPI Yet another Java API API Documentation |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |