public class OneRowFlowLayout extends FlowLayout
FlowLayout
to create a particular version
of this type of layout.
In details, this class implements a layout that acts as the FlowLayout
layout until there is enough space in the container to position all the components
inside one single row.
When there is not enough space for positioning all the components in one single line
inside the container, differently from the FlowLayout
layout that starts putting
the remaining components on a new line and continues on this way until all of them are
positioned, the OneRowFlowLayout
layout resizes the components to maintain them
all in one single row.
FlowLayout
,
Serialized FormModifier and Type | Field and Description |
---|---|
private static long |
serialVersionUID
Auto-Generated Serial Version UID for this class.
|
Constructor and Description |
---|
OneRowFlowLayout()
Constructor with no parameters that calls the
OneRowFlowLayout(int, int, int)
constructor to create a layout with default parameters (align=LEFT, hgap=0, vgap=0). |
OneRowFlowLayout(int align)
Constructor with alignment parameter that calls the
OneRowFlowLayout(int, int, int)
constructor to create a layout with the specified alignment and default hgap and vgap
(hgap=0, vgap=0). |
OneRowFlowLayout(int align,
int hgap,
int vgap)
Constructor with alignment, horizontal gap and vertical gap parameters that calls
the super class constructor to create a layout with the specified information.
|
Modifier and Type | Method and Description |
---|---|
void |
layoutContainer(Container target)
Lays out the container.
|
private Dimension |
selectSize(Dimension wantedSize,
Dimension maxPossibleSize)
This method returns a new dimension built with the smallest width and height
of the two dimensions passed as parameters.
|
addLayoutComponent, getAlignment, getAlignOnBaseline, getHgap, getVgap, minimumLayoutSize, preferredLayoutSize, removeLayoutComponent, setAlignment, setAlignOnBaseline, setHgap, setVgap, toString
private static final long serialVersionUID
public OneRowFlowLayout()
OneRowFlowLayout(int, int, int)
constructor to create a layout with default parameters (align=LEFT, hgap=0, vgap=0).public OneRowFlowLayout(int align)
OneRowFlowLayout(int, int, int)
constructor to create a layout with the specified alignment and default hgap and vgap
(hgap=0, vgap=0).align
- alignment of the positioned componentspublic OneRowFlowLayout(int align, int hgap, int vgap)
align
- alignment of the positioned componentshgap
- horizontal gap between componentsvgap
- vertical gap between componentspublic void layoutContainer(Container target)
When there is not enough space for positioning all the components with their preferred size in one single row inside the container, the method finds the maximum possible component size for displaying all the components in one single row; then it positions every component using its preferred size if smaller than the maximum possible one, the maximum possible size otherwise.
layoutContainer
in interface LayoutManager
layoutContainer
in class FlowLayout
target
- the specified container being laid outprivate Dimension selectSize(Dimension wantedSize, Dimension maxPossibleSize)
wantedSize
- the dimension wanted by the componentmaxPossibleSize
- the maximum possible dimension for the component