LayoutManager2 (Java Platform SE 8 ) (original) (raw)
- All Superinterfaces:
LayoutManager
All Known Implementing Classes:
BasicSplitPaneUI.BasicHorizontalLayoutManager, BasicSplitPaneUI.BasicVerticalLayoutManager, BorderLayout, BoxLayout, CardLayout, DefaultMenuLayout, GridBagLayout, GroupLayout, JRootPane.RootLayout, OverlayLayout, SpringLayout
public interface LayoutManager2
extends LayoutManager
Defines an interface for classes that know how to layout Containers based on a layout constraints object. This interface extends the LayoutManager interface to deal with layouts explicitly in terms of constraint objects that specify how and where components should be added to the layout.
This minimal extension to LayoutManager is intended for tool providers who wish to the creation of constraint-based layouts. It does not yet provide full, general support for custom constraint-based layout managers.
See Also:
LayoutManager, Container
Method Summary
All Methods Instance Methods Abstract Methods
Modifier and Type Method Description void addLayoutComponent(Component comp,Object constraints) Adds the specified component to the layout, using the specified constraint object. float getLayoutAlignmentX(Container target) Returns the alignment along the x axis. float getLayoutAlignmentY(Container target) Returns the alignment along the y axis. void invalidateLayout(Container target) Invalidates the layout, indicating that if the layout manager has cached information it should be discarded. Dimension maximumLayoutSize(Container target) Calculates the maximum size dimensions for the specified container, given the components it contains. * ### Methods inherited from interface java.awt.[LayoutManager](../../java/awt/LayoutManager.html "interface in java.awt") `[addLayoutComponent](../../java/awt/LayoutManager.html#addLayoutComponent-java.lang.String-java.awt.Component-), [layoutContainer](../../java/awt/LayoutManager.html#layoutContainer-java.awt.Container-), [minimumLayoutSize](../../java/awt/LayoutManager.html#minimumLayoutSize-java.awt.Container-), [preferredLayoutSize](../../java/awt/LayoutManager.html#preferredLayoutSize-java.awt.Container-), [removeLayoutComponent](../../java/awt/LayoutManager.html#removeLayoutComponent-java.awt.Component-)`
Method Detail
* #### addLayoutComponent void addLayoutComponent([Component](../../java/awt/Component.html "class in java.awt") comp, [Object](../../java/lang/Object.html "class in java.lang") constraints) Adds the specified component to the layout, using the specified constraint object. Parameters: `comp` \- the component to be added `constraints` \- where/how the component is added to the layout. * #### maximumLayoutSize [Dimension](../../java/awt/Dimension.html "class in java.awt") maximumLayoutSize([Container](../../java/awt/Container.html "class in java.awt") target) Calculates the maximum size dimensions for the specified container, given the components it contains. See Also: [Component.getMaximumSize()](../../java/awt/Component.html#getMaximumSize--), [LayoutManager](../../java/awt/LayoutManager.html "interface in java.awt") * #### getLayoutAlignmentX float getLayoutAlignmentX([Container](../../java/awt/Container.html "class in java.awt") target) Returns the alignment along the x axis. This specifies how the component would like to be aligned relative to other components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is centered, etc. * #### getLayoutAlignmentY float getLayoutAlignmentY([Container](../../java/awt/Container.html "class in java.awt") target) Returns the alignment along the y axis. This specifies how the component would like to be aligned relative to other components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is centered, etc. * #### invalidateLayout void invalidateLayout([Container](../../java/awt/Container.html "class in java.awt") target) Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2025, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.