javax.swing
Class SpringLayout
- LayoutManager, LayoutManager2
A very flexible layout manager. Components are laid out by defining the
relationships between them. The relationships are expressed as
Spring
s. You can attach a Spring for each edge of a component and
link it to an edge of a different component. For example, you can say,
the northern edge of component A should be attached to the southern edge
of component B, and the space between them should be something between
x and y pixels, and preferably z pixels.
While quite simple, this layout manager can be used to emulate most other
layout managers, and can also be used to solve some layout problems, which
would be hard to solve with other layout managers.
void | addLayoutComponent(Component component, Object constraint) - Adds a layout component and a constraint object to this layout.
|
void | addLayoutComponent(String name, Component c) - Adds a layout component and a constraint object to this layout.
|
Spring | getConstraint(String edgeName, Component c) - Returns the constraint of the edge named by
edgeName .
|
SpringLayout.Constraints | getConstraints(Component c) - Returns the
SpringLayout.Constraints object associated with the specified
component.
|
float | getLayoutAlignmentX(Container p) - Returns the X alignment of the Container
p .
|
float | getLayoutAlignmentY(Container p) - Returns the Y alignment of the Container
p .
|
void | invalidateLayout(Container p) - Recalculate a possibly cached layout.
|
void | layoutContainer(Container p) - Lays out the container
p .
|
Dimension | maximumLayoutSize(Container p) - Calculates the maximum size of the layed out container.
|
Dimension | minimumLayoutSize(Container p) - Calculates the minimum size of the layed out container.
|
Dimension | preferredLayoutSize(Container p) - Calculates the preferred size of the layed out container.
|
void | putConstraint(String e1, Component c1, int pad, String e2, Component c2) - Attaches the edge
e1 of component c1 to
the edge e2 of component c2 width the
fixed strut pad .
|
void | putConstraint(String e1, Component c1, Spring s, String e2, Component c2) - Attaches the edge
e1 of component c1 to
the edge e2 of component c2 width the
Spring s .
|
void | removeLayoutComponent(Component c) - Removes a layout component.
|
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
EAST
public static final String EAST
The right edge of a component.
NORTH
public static final String NORTH
The top edge of a component.
SOUTH
public static final String SOUTH
The bottom edge of a component.
WEST
public static final String WEST
The left edge of a component.
SpringLayout
public SpringLayout()
Creates a new SpringLayout.
addLayoutComponent
public void addLayoutComponent(String name,
Component c)
Adds a layout component and a constraint object to this layout.
This method is usually only called by a
Container
s add
method. This method does nothing, since SpringLayout does not manage
String-indexed components.
- addLayoutComponent in interface LayoutManager
name
- the name.c
- the component to be added.
getConstraint
public Spring getConstraint(String edgeName,
Component c)
Returns the constraint of the edge named by edgeName
.
edgeName
- the name of the edge, one of EAST
,
WEST
, NORTH
or SOUTH
.c
- the component from which to get the constraint.
- the constraint of the edge
edgeName
of the
component c.
putConstraint
public void putConstraint(String e1,
Component c1,
int pad,
String e2,
Component c2)
Attaches the edge e1
of component c1
to
the edge e2
of component c2
width the
fixed strut pad
.
e1
- the edge of component 1.c1
- the component 1.pad
- the space between the components in pixels.e2
- the edge of component 2.c2
- the component 2.
putConstraint
public void putConstraint(String e1,
Component c1,
Spring s,
String e2,
Component c2)
Attaches the edge
e1
of component
c1
to
the edge
e2
of component
c2
width the
Spring
s
.
e1
- the edge of component 1.c1
- the component 1.s
- the space between the components as a Spring
object.e2
- the edge of component 2.c2
- the component 2.
SpringLayout.java --
Copyright (C) 2004, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.