|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.frag.umlplugin.guilayout.LayoutBuilder
public class LayoutBuilder
The LayoutBuilder is a convenience class for building hierarchical FlexLayout GUI layouts. The following example should illustrate the basic functionality:
To create this GUI the following code does all the layout after the GUI elements itself are created.
LayoutBuilder builder = new LayoutBuilder (); builder.setDefaultInsets (new Insets (2, 2, 2, 2)); JPanel root = builder.beginV (); builder.beginH (); // selection area builder.beginV (); // box with available computers builder.add (availableLabel, CENTER); builder.add (availableScroller, STRETCH_XY); builder.end (); builder.beginV (); // buttons to add/remove computers builder.add (add, FILL_X); builder.add (remove, FILL_X); builder.end (); builder.beginV (); // box with selected computers builder.add (selectedLabel, CENTER); builder.add (selectedScroller, STRETCH_XY); builder.end (); builder.end (); // end of selection area builder.beginH (4); builder.add (hostLabel, LABEL); builder.add (hostField, STRETCH_X); builder.add (ipLabel, LABEL); builder.add (ipField, STRETCH_X); builder.add (osLabel, LABEL); builder.add (osField, STRETCH_X); builder.add (roomLabel, LABEL); builder.add (roomField, STRETCH_X); builder.end (); builder.beginH (); builder.add (okButton, MAX_X); builder.addHSpace (); builder.add (cancelButton, MAX_X); builder.end (); builder.end ();
This is a simple example, that uses a border layout:
JPanel root = new JPanel (new BorderLayout ()); root.add (north, BorderLayout.NORTH); root.add (south, BorderLayout.SOUTH); root.add (west, BorderLayout.WEST); root.add (east, BorderLayout.EAST); root.add (center, BorderLayout.CENTER);The following code simulates this border layout using FlexLayout:
LayoutBuilder builder = new LayoutBuilder (); JPanel root = builder.beginV (); builder.add (north, STRETCH_X); builder.beginH (); builder.add (west, STRETCH_Y); builder.add (center, STRETCH_XY); builder.add (east, STRETCH_Y); builder.end (); builder.add (south, STRETCH_X); builder.end ();
Constructor Summary | |
---|---|
LayoutBuilder()
Construct a new LayoutBuilder. |
|
LayoutBuilder(java.awt.Container root,
FlexLayout layout)
Create a new LayoutBuilder, that sets a the specified FlexLayout as layout manager for the given container and then uses the given Container as root container. |
Method Summary | |
---|---|
void |
add(java.awt.Component component,
java.lang.Object constraints)
Add the given component to the current container using the given constraints. |
void |
addHSpace()
Add some horizontal flexible space to create a gap between other components. |
void |
addHSpace(int pixels)
Add some horizontal fixed space to create a gap between other components. |
void |
addVSpace()
Add some vertical flexible space to create a gap between other components. |
void |
addVSpace(int pixels)
Add some vertical fixed space to create a gap between other components. |
javax.swing.JPanel |
beginBorder()
Begin a new border layout hierarchy level of components. |
javax.swing.JPanel |
beginH()
Begin a new horizontal hierarchy level of components. |
javax.swing.JPanel |
beginH(int columns)
Begin a new horizontal hierarchy level of components. |
javax.swing.JPanel |
beginV()
Begin a new vertical hierarchy level of components. |
javax.swing.JPanel |
beginV(int rows)
Begin a new vertical hierarchy level of components. |
void |
end()
Leave the current container hierarchy level. |
void |
end(java.lang.Object constraints)
Leave the current container hierarchy level. |
java.awt.Insets |
getDefaultComponentInsets()
Get the default insets, that are used for all components, that are added with null insets. |
java.awt.Insets |
getDefaultContainerInsets()
Get the default insets, that are used for all containers, that are added with null insets. |
void |
setDefaultComponentInsets(java.awt.Insets insets)
Set the default insets, that will be used for all components, that are added with null insets. |
void |
setDefaultContainerInsets(java.awt.Insets insets)
Set the default insets, that will be used for all containers, that are added with null insets. |
void |
setDefaultInsets(java.awt.Insets insets)
Set the default insets, that will be used for all components or containers, that are added with null insets. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public LayoutBuilder()
public LayoutBuilder(@NotNull java.awt.Container root, @NotNull FlexLayout layout)
root
- root containerlayout
- layout manager to use for the root containerMethod Detail |
---|
public void setDefaultInsets(@Nullable java.awt.Insets insets)
null
insets.
insets
- new default insetspublic void setDefaultComponentInsets(@Nullable java.awt.Insets insets)
null
insets.
insets
- new default insetspublic void setDefaultContainerInsets(@Nullable java.awt.Insets insets)
null
insets.
insets
- new default insets@NotNull public java.awt.Insets getDefaultComponentInsets()
null
insets.
@NotNull public java.awt.Insets getDefaultContainerInsets()
null
insets.
@NotNull public javax.swing.JPanel beginH()
add
, are arranged
horizontally. So the new component hierarchy will be an irregular
raster of components with one row and an arbitrary number of columns.
@NotNull public javax.swing.JPanel beginH(int columns)
add
, are arranged
horizontally until the specified number of columns is reached and
a new row of components is created. So the new component hierarchy
will be an irregular raster of components with a fixed number of
columns and an arbitrary number of rows.
columns
- maximum number of columns
@NotNull public javax.swing.JPanel beginV()
add
, are arranged
vertically. So the new component hierarchy will be an irregular
raster of components with one column and an arbitrary number of rows.
@NotNull public javax.swing.JPanel beginV(int rows)
add
, are arranged
vertically until the specified number of rows is reached and
a new column of components is created. So the new component hierarchy
will be an irregular raster of components with a fixed number of
rows and an arbitrary number of columns.
rows
- maximum number of rows
@NotNull public javax.swing.JPanel beginBorder()
add
, are arranged
using a border layout
public void end()
begin
-methods, a
java.util.EmptyStackException
will be raised.
public void end(@Nullable java.lang.Object constraints)
begin
-methods, a
java.util.EmptyStackException
will be raised.
constraints
- constraints to use for finished panelpublic void add(@NotNull java.awt.Component component, @Nullable java.lang.Object constraints)
component
- component to addconstraints
- constraints to use for the given componentpublic void addHSpace()
public void addHSpace(int pixels)
pixels
- width of space in pixelspublic void addVSpace()
public void addVSpace(int pixels)
pixels
- height of space in pixels
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |