views:

107

answers:

2

Please help me how to creat own custom layout, container, component, layout manager... Example: Containers and Layout Managers

  • Create a window frame.
  • Nest panels within a frame for better layout control.
  • Create and display buttons in a panel.
  • List two component attributes that are controlled by a layout manager.
  • Set the layout manager for a container.
  • Place components in a panel using BorderLayout, GridLayout, and FlowLayout.
  • Name one advantage of each of the layout managers.
  • Create panels with titles.

i was search on google but can't find any that match my requirement

Thanks for your help Edit: I was found with keyword "Open Source UI"

+1  A: 

You could use the following set of tutorials: http://java.sun.com/docs/books/tutorial/uiswing/.

rochb
Thanks for your link, i am reading:http://java.sun.com/docs/books/tutorial/uiswing/layout/
nguyendat
+1  A: 

Create a window frame

new JFrame();

Nest panels within a frame for better layout control

final JFrame jframe = new JFrame();
final JPanel innerOne = new JPanel();
jframe.add(innerOne);
innerOne.add(otherComponents);

Create and display buttons in a panel

innerOne.add(new JButton("Hello World!"));

List two component attributes that are controlled by a layout manager

Obviously check out JavaDoc of BorderLayout: BorderLayout.NORTH and SOUTH

Set the layout manager for a container

innerOne.setLayout(...);

Place components in a panel using BorderLayout, ...

Just apply the layout, and add providing the arguments for the LayoutManager:

innerOne.setLayout(new BorderLayout());
innerOne.add(..., BorderLayout.NORTH);

Name one advantage of each of the layoutmanager.

Check out the JavaDoc's. They are really helpful in these situations.

Create panels with titles.

innerOne.setBorder(new TitledBorder("Hello World"));
Pindatjuh
Thanks for your example, can your refer any resource Thanks
nguyendat