I am using the following:
java.awt.Container.add(Component comp, Object constraints)
How do I specificy the constraints object? I need to be able to place a component within the container.
Oh and my class extends JInternalFrame if this helps…
I need to specify coordinates to place the component within the container
The
constraintsobjects depends on which layout manager you are using.For example, with a
BorderLayoutyou will have just some constants:container.add(element, BorderLayout.CENTER)While if the layout manager of the container is a
GridBagLayoutyou will have aGridBagConstraintsobject with the specified parameters.Some layout managers (like
FlowLayoutorGridLayout) don’t need any kind of constraint since they actually decide how to place things by themselves.As a side note, if you need absolute positioning you will not have any layout manager: