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
FieldsModifier and TypeFieldDescriptionstatic final intCommon padding width where padding or border is wanted.static final booleanstatic final boolean -
Constructor Summary
ConstructorsConstructorDescriptionSBoxLayout(boolean direction) Create a new SBoxLayout.SBoxLayout(boolean direction, int padding) Create a new SBoxLayout with padding between components. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLayoutComponent(Component component, Object flags) voidaddLayoutComponent(String id, Component component) static JComponentAdd a utility component that expands by default, to a container using SBoxLayout.static Objectconstraint(SLayout... flags) Create a constraints object.static JComponentcreateContainer(boolean direction) A convenience method for creating a container using SBoxLayout.static JComponentcreateContainer(boolean direction, int padding) A convenience method for creating a container using SBoxLayout with padding between the components.floatgetLayoutAlignmentX(Container target) floatgetLayoutAlignmentY(Container target) voidinvalidateLayout(Container target) voidlayoutContainer(Container parent) maximumLayoutSize(Container parent) minimumLayoutSize(Container parent) preferredLayoutSize(Container parent) voidremoveLayoutComponent(Component component) final voidsetPadding(int padding) Set the padding between the components.
-
Field Details
-
VERTICAL
public static final boolean VERTICAL- See Also:
-
HORIZONTAL
public static final boolean HORIZONTAL- See Also:
-
COMMON_PADDING
public static final int COMMON_PADDINGCommon padding width where padding or border is wanted.- See Also:
-
-
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:
addLayoutComponentin interfaceLayoutManager2
-
addLayoutComponent
- Specified by:
addLayoutComponentin interfaceLayoutManager
-
getLayoutAlignmentX
- Specified by:
getLayoutAlignmentXin interfaceLayoutManager2
-
getLayoutAlignmentY
- Specified by:
getLayoutAlignmentYin interfaceLayoutManager2
-
invalidateLayout
- Specified by:
invalidateLayoutin interfaceLayoutManager2
-
layoutContainer
- Specified by:
layoutContainerin interfaceLayoutManager
-
maximumLayoutSize
- Specified by:
maximumLayoutSizein interfaceLayoutManager2
-
minimumLayoutSize
- Specified by:
minimumLayoutSizein interfaceLayoutManager
-
preferredLayoutSize
- Specified by:
preferredLayoutSizein interfaceLayoutManager
-
removeLayoutComponent
- Specified by:
removeLayoutComponentin 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
-