Basic HTML version of Foils prepared 18 May 97

Foil 54 Layout of Components in a Panel

From Java Tutorial - Spring 1997 Part 3:Graphics and the Abstract Windowing Toolkit Peking Tutorial, Web Certificate -- Spring-Summer 1997. by Nancy J. McCracken,Geoffrey C. Fox


The various panels in a container are laid out separately in terms of their subcomponents
One can lay components out "by hand" with positioning in pixel space
However this is very difficult to make machine independent. Thus one tends to use general strategies which are embodied in 5 LayoutMangers which all implement the LayoutManager Interface. One can expect further custom LayoutManager's to become available on the Web
setLayout(new FlowLayout()); // creates a basic flow layout in your panel -- actually unnecessary as default
Other available LayoutManager's are GridLayout(), BorderLayout() (default for Frame's), CardLayout() (Used for dynamic layouts) and GridBagLayout() (the most flexible)



© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Thu Jan 8 1998