11-Layout-Managers

11-Layout-Managers - 2006 Marty Hall Layout Managers...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
2 J2EE Training: http://courses.coreservlets.com/ Servlets, JSP, Struts, JSF, Hibernate, AJAX, Java 5, etc. Developed and taught by well-known author and developer. At public venues or onsite at your location. © 2006 Marty Hall Layout Managers Arranging Elements in Windows 3 Developed and taught by well-known author and developer. At public venues or onsite at your location. © 2006 Marty Hall For live Java training, please see training courses at http://courses.coreservlets.com/. Servlets, JSP, Struts, JSF, AJAX, Java 5, etc. Taught by the author of Core Servlets and JSP , More Servlets and JSP , and this tutorial. Available at public venues, or customized versions can be held on-site at your organization.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 J2EE training: http://courses.coreservlets.com Agenda How layout managers simplify interface design Standard layout managers FlowLayout, BorderLayout, CardLayout, GridLayout, GridBagLayout, BoxLayout Positioning components manually Strategies for using layout managers effectively Using invisible components 5 J2EE training: http://courses.coreservlets.com Layout Managers Assigned to each Container Give sizes and positions to components in the window Helpful for windows whose size changes or that display on multiple operating systems Relatively easy for simple layouts But, it is surprisingly hard to get complex layouts with a single layout manager Controlling complex layouts Use nested containers (each with its own layout manager) Use invisible components and layout manager options Write your own layout manager Turn some layout managers off and arrange some things manually
Background image of page 2
6 J2EE training: http://courses.coreservlets.com FlowLayout Default layout for Panel, JPanel, and Applet Behavior Resizes components to their preferred size Places components in rows left to right , top to bottom Rows are centered by default Constructors FlowLayout() Centers each row and keeps 5 pixels between entries in a row and between rows FlowLayout(int alignment) Same 5 pixels spacing, but changes the alignment of the rows FlowLayout.LEFT, FlowLayout.RIGHT, FlowLayout.CENTER FlowLayout(int alignment, int hGap, int vGap) Specify the alignment as well as the horizontal and vertical spacing between components (in pixels) 7 J2EE training: http://courses.coreservlets.com FlowLayout: Example public class FlowTest extends Applet { public void init() { // setLayout(new FlowLayout()); [Default] for(int i=1; i<6; i++) { add(new Button("Button " + i)); } } }
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
8 J2EE training: http://courses.coreservlets.com BorderLayout Default for Frame, JFrame, Dialog, JApplet Behavior Divides the Container into five regions Each region is identified by a corresponding BorderLayout constant NORTH , SOUTH , EAST , WEST , and CENTER NORTH and SOUTH respect the preferred height of the component EAST and WEST respect the preferred width of the component CENTER is given the remaining space Is allowing a maximum of five components too restrictive? Why not?
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 23

11-Layout-Managers - 2006 Marty Hall Layout Managers...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online