-2

What is the use of Container in Swing?

0

4 Answers 4

4

A Swing Container is a component that holds or wraps-up other components. It aids with grouping related components together in the GUI. There are a lot of resources on the web that explain how to use Containers.

1

A container in Swing is something that holds other components.

A container is responsible to displaying the components according to your layout.

If a button is placed on the top left corner, every time the window is re-sized, the button will still be on the top left corner. This is because the container is containing the button and at the same time containing its layout position. That is why it's container.setLayout() and container.add()

In Java Swing, a lot of components can be a container. A JButton can be a container, and so can a JLabel. JPanel is also a container, and anything that extends those three can also be a container.

0

Well ... Containers are used to contain other widgets, and to help arrange them in a way that suits the design of the UI.

For instance, JPanel is a general-purpose container. Together with a LayoutManager, you can get many different layouts of widgets.

0

Container can has other compoments or container. it can be three level.

  1. top level .such as JFrame, JDialog,JApplet.these containers can't be contained.
  2. immediate container ,such as Jpanel we ofen use
  3. low level. So this is what we know as low level components.

Not the answer you're looking for? Browse other questions tagged or ask your own question.