Creating a Container

A container holds one or more child components. A container has a layout that determines how the child components are arranged within the container. This example creates a frame with a text area in the center and a row of buttons at the bottom. The buttons are placed in a container.
// Create a container with a flow layout, which arranges its children horizontally
Panel panel = new Panel();

// A container can also be created with a specific layout
panel = new Panel(new FlowLayout(FlowLayout.RIGHT));

// Add several buttons to the container
panel.add(new Button("A"));
panel.add(new Button("B"));
panel.add(new Button("C"));

// Create frame with a text area in the center
Frame frame = new Frame();
Component comp = new TextArea();
frame.add(comp, BorderLayout.CENTER);

// Add the container to the bottom of the frame
frame.add(panel, BorderLayout.SOUTH);

// Show the frame
int width = 300;
int height = 300;
frame.setSize(width, height);
frame.setVisible(true);

Comments

26 Jul 2010 - 12:44am by cheap wedding dresses (not verified)

This example creates a frame with a text area in the center and a row of buttons at the bottom. The buttons are placed in a container.

30 Mar 2011 - 3:01am by Anonymous (not verified)

I want to ask about this comment box.how do you set it? I'm new with programming.this comment box really something I'm looking for

10 Apr 2011 - 6:03pm by Anonymous (not verified)

Look for this comment box

20 Apr 2011 - 2:42am by Anonymous (not verified)

There is JAVA,why so many ads in my eyes...

21 Apr 2011 - 12:58am by cheap coach handbags (not verified)

Cheap Coach handbags in the American market leading position of instability, while also positive to expand the international distribution market business, attract overseas consumers. Currently, Mr Coates (Coach) has been more than 20 countries outside America opened outlets and outlets, gradually realize the global development strategy.

5 May 2011 - 8:18pm by Anonymous (not verified)

That's great

12 Sep 2011 - 6:35pm by North Face Coupons (not verified)

The article is worth reading,Thank you very much! I will keep your new articles.

11 Nov 2011 - 9:13am by galaxy (not verified)

The first time Sam and I tested it,we had it hooked into a laptop and also reasoned
that we are only three blocks from a fire station so the paramedics could get here
pretty quick (Flawed reasoning? perhaps).

15 Nov 2011 - 4:32am by Anonymous (not verified)

You know so much about this subject. So much so that you made me want to learn more about it. Your blog is my stepping stone, my friend. Thanks for the heads up on this subject.You know so much about this subject. So much so that you made me want to learn more about it. Your blog is my stepping stone, my friend. Thanks for the heads up on this subject.

9 Feb 2012 - 11:41pm by Monster Beats Studio Nate Robinson (not verified)

Thank you for sharing with us , with everyone happy

9 Mar 2012 - 6:38am by floppy (not verified)

This was a great example thank you

My only problem was that no listener was added to the exit

Add this and all will be well :)

after the frame has been made add this

// make the exit button functional so exit works
frame.addWindowListener(new WindowAdapter(){

public void windowClosing(WindowEvent we){

System.exit(0);

}
});

4 Apr 2012 - 8:42pm by gjfdjd (not verified)

A person can put the particular cut video clip with every single video keep track of to apply consequence. You'll be able to established the particular 'picture organize' computer software within the video. Therefore you'll be able to enjoy training videos part by means of part for the filter. For instance, in several information areas video publisher applies this particular impact on functions when he wants to indicate a new facts single point within the facilities interacting with the particular news reporter with site.

Post a comment

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image. Ignore spaces and be careful about upper and lower case.