Package games.stendhal.client.gui.layout
Class SBoxLayout
java.lang.Object
games.stendhal.client.gui.layout.SBoxLayout
- All Implemented Interfaces:
LayoutManager
,LayoutManager2
A simple layout manager that does what BoxLayout fails to do,
and provides a predictable layout with few hidden interactions.
Minimum size is properly supported within reasonable limits.
Maximum size has only a soft support, i.e. maximum size works as a limiting preferred size, even if the child component itself would suggest a larger size.
Component alignment is supported in the direction perpendicular to the layout direction.
SBoxLayout supports constraints of type SLayout
. A single constraint
flag can passed as the second parameter to
Container.add(Component c, Object constraint)
. Constraints can
be combined using the object returned by constraint(SLayout...)
as
the constraints object.
-
Field Summary
Modifier and TypeFieldDescriptionstatic int
Common padding width where padding or border is wanted.static boolean
static boolean
-
Constructor Summary
ConstructorDescriptionSBoxLayout(boolean direction)
Create a new SBoxLayout.SBoxLayout(boolean direction, int padding)
Create a new SBoxLayout with padding between components. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addLayoutComponent(Component component, Object flags)
void
addLayoutComponent(String id, Component component)
static JComponent
Add a utility component that expands by default, to a container using SBoxLayout.static Object
constraint(SLayout... flags)
Create a constraints object.static JComponent
createContainer(boolean direction)
A convenience method for creating a container using SBoxLayout.static JComponent
createContainer(boolean direction, int padding)
A convenience method for creating a container using SBoxLayout with padding between the components.float
getLayoutAlignmentX(Container target)
float
getLayoutAlignmentY(Container target)
void
invalidateLayout(Container target)
void
layoutContainer(Container parent)
maximumLayoutSize(Container parent)
minimumLayoutSize(Container parent)
preferredLayoutSize(Container parent)
void
removeLayoutComponent(Component component)
void
setPadding(int padding)
Set the padding between the components.
-
Field Details
-
VERTICAL
public static final boolean VERTICAL- See Also:
- Constant Field Values
-
HORIZONTAL
public static final boolean HORIZONTAL- See Also:
- Constant Field Values
-
COMMON_PADDING
public static final int COMMON_PADDINGCommon padding width where padding or border is wanted.- See Also:
- Constant Field Values
-
-
Constructor Details
-
SBoxLayout
public SBoxLayout(boolean direction)Create a new SBoxLayout.- Parameters:
direction
- layout direction
-
SBoxLayout
public SBoxLayout(boolean direction, int padding)Create a new SBoxLayout with padding between components.- Parameters:
direction
- layout directionpadding
- component padding in pixels
-
-
Method Details
-
constraint
Create a constraints object.- Parameters:
flags
- constraint flags- Returns:
- constraints object
-
setPadding
public final void setPadding(int padding)Set the padding between the components. Typically you should use either 0 (the default), or COMMON_PADDING for consistent look. For the padding around everything use appropriate empty border instead.- Parameters:
padding
- pixel width of the padding
-
addLayoutComponent
- Specified by:
addLayoutComponent
in interfaceLayoutManager2
-
addLayoutComponent
- Specified by:
addLayoutComponent
in interfaceLayoutManager
-
getLayoutAlignmentX
- Specified by:
getLayoutAlignmentX
in interfaceLayoutManager2
-
getLayoutAlignmentY
- Specified by:
getLayoutAlignmentY
in interfaceLayoutManager2
-
invalidateLayout
- Specified by:
invalidateLayout
in interfaceLayoutManager2
-
layoutContainer
- Specified by:
layoutContainer
in interfaceLayoutManager
-
maximumLayoutSize
- Specified by:
maximumLayoutSize
in interfaceLayoutManager2
-
minimumLayoutSize
- Specified by:
minimumLayoutSize
in interfaceLayoutManager
-
preferredLayoutSize
- Specified by:
preferredLayoutSize
in interfaceLayoutManager
-
removeLayoutComponent
- Specified by:
removeLayoutComponent
in interfaceLayoutManager
-
addSpring
Add a utility component that expands by default, to a container using SBoxLayout. Adding it rather than just creating the component is a workaround for components not passing information about new subcomponents if the user explicitly specifies the constraints.- Parameters:
target
- the container where to add a string to- Returns:
- A spring with preferred dimensions 0, 0.
-
createContainer
A convenience method for creating a container using SBoxLayout.- Parameters:
direction
- layout direction- Returns:
- A component using SBoxLayout
-
createContainer
A convenience method for creating a container using SBoxLayout with padding between the components.- Parameters:
direction
- layout directionpadding
- padding in pixels between the components- Returns:
- A component using SBoxLayout
-