java.lang.Object
org.autogui.swing.util.ResizableFlowLayout
- All Implemented Interfaces:
LayoutManager
a layout manager for lining up components horizontally or vertically.
orientation = true; //horizontal [comp1] [comp2] ...
orientation = false; //vertical [comp1] [comp2] ...
Width or height of each component can be resizable or fixed. If the size is fixed, the manager refers preferred size and minimum size of a component.
To manage components, it needs to manually add them to the manager.
add(Container, Component, boolean)
is the convenient method for the task.
JPanel pane = new JPanel(); ResizableFlowLayout layout = new ResizableFlowLayout(true); //horizontal pane.setLayout(layout); ResizableFlowLayout.add(pane, new JLabel("Message:"), false); //fixed ResizableFlowLayout.add(pane, new JTextField(""), true); //resizable
ResizableFlowLayout.LayoutAppender
is a factory for creating a pane with the layout.
It can be created by create(boolean)
.
JPanel pane = ResizableFlowLayout.create(false) //vertical .add(ResizableFlowLayout.create(true) .add(new JLabel("Message:")).add(new JTextField(""), true).getContainer()) .add(ResizableFlowLayout.create(true) .add(new JLabel("Name:")).add(new JTextField(""), true).getContainer()) .getContainer();
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
a class for providing fluent interface for constructingResizableFlowLayout
class
internal state for calculating layout. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionResizableFlowLayout
(boolean horizontalOrientation) ResizableFlowLayout
(boolean horizontalOrientation, int margin) -
Method Summary
Modifier and TypeMethodDescriptionstatic void
void
addLayoutComponent
(String name, Component comp) create
(boolean horizontalOrientation) create
(boolean horizontalOrientation, boolean fitOpposite) int
static int
insetsHeight
(Insets insets) static int
insetsWidth
(Insets insets) boolean
boolean
boolean
isResizable
(Component comp) boolean
void
layoutContainer
(Container parent) minimumLayoutSize
(Container parent) preferredLayoutSize
(Container parent) void
static void
void
setFitHeight
(boolean fitHeight) Here, the word "height" means opposite orientation of lining orientation.void
setMargin
(int margin) void
setResizable
(Component comp, boolean r) <CT extends Container>
ResizableFlowLayout.LayoutAppender<CT> withContainer
(CT parent)
-
Field Details
-
margin
protected int margin -
orientation
protected boolean orientation -
fitHeight
protected boolean fitHeight -
resizable
-
-
Constructor Details
-
ResizableFlowLayout
public ResizableFlowLayout(boolean horizontalOrientation, int margin) -
ResizableFlowLayout
public ResizableFlowLayout(boolean horizontalOrientation)
-
-
Method Details
-
create
-
create
public static ResizableFlowLayout.LayoutAppender<JPanel> create(boolean horizontalOrientation, boolean fitOpposite) -
setFitHeight
Here, the word "height" means opposite orientation of lining orientation.- Parameters:
fitHeight
- the flag- Returns:
- this
-
isFitHeight
public boolean isFitHeight() -
isVertical
public boolean isVertical() -
isHorizontal
public boolean isHorizontal() -
setMargin
public void setMargin(int margin) -
getMargin
public int getMargin() -
setResizable
-
isResizable
-
insetsWidth
-
insetsHeight
-
layoutContainer
- Specified by:
layoutContainer
in interfaceLayoutManager
-
minimumLayoutSize
- Specified by:
minimumLayoutSize
in interfaceLayoutManager
-
preferredLayoutSize
- Specified by:
preferredLayoutSize
in interfaceLayoutManager
-
addLayoutComponent
- Specified by:
addLayoutComponent
in interfaceLayoutManager
-
removeLayoutComponent
- Specified by:
removeLayoutComponent
in interfaceLayoutManager
-
add
-
remove
-
remove
-
withContainer
-