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 classa class for providing fluent interface for constructingResizableFlowLayoutclassinternal state for calculating layout. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionResizableFlowLayout(boolean horizontalOrientation) ResizableFlowLayout(boolean horizontalOrientation, int margin) -
Method Summary
Modifier and TypeMethodDescriptionstatic voidvoidaddLayoutComponent(String name, Component comp) create(boolean horizontalOrientation) create(boolean horizontalOrientation, boolean fitOpposite) intstatic intinsetsHeight(Insets insets) static intinsetsWidth(Insets insets) booleanbooleanbooleanisResizable(Component comp) booleanvoidlayoutContainer(Container parent) minimumLayoutSize(Container parent) preferredLayoutSize(Container parent) voidstatic voidvoidsetFitHeight(boolean fitHeight) Here, the word "height" means opposite orientation of lining orientation.voidsetMargin(int margin) voidsetResizable(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:
layoutContainerin interfaceLayoutManager
-
minimumLayoutSize
- Specified by:
minimumLayoutSizein interfaceLayoutManager
-
preferredLayoutSize
- Specified by:
preferredLayoutSizein interfaceLayoutManager
-
addLayoutComponent
- Specified by:
addLayoutComponentin interfaceLayoutManager
-
removeLayoutComponent
- Specified by:
removeLayoutComponentin interfaceLayoutManager
-
add
-
remove
-
remove
-
withContainer
-