SlideServe
Menu
Préférences
© SlideServe · v2026

AWT Layout Managers (Chapter 10)

arleen avatar
15 diapositives · 423 Views · May 03, 2013

AWT Layout Managers (Chapter 10). Java Certification Study Group January 21, 1999 Mark Roth. GridLayout. BorderLayout. LayoutManager. FlowLayout. Layout Managers. Layout Managers. Removes repetitious need to lay out components precisely.

AWT Layout Managers (Chapter 10) - slide 1
01 / 15AWT Layout Managers (Chapter 10)
1 / 17

Télécharger la présentation

AWT Layout Managers (Chapter 10)
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. AWT Layout Managers(Chapter 10) Java Certification Study Group January 21, 1999 Mark Roth

  2. GridLayout BorderLayout LayoutManager FlowLayout Layout Managers

  3. Layout Managers • Removes repetitious need to lay out components precisely. • Insulates developer from the fact that components have different sizes when instantiated on different platforms. • All implement java.awt.LayoutManager interface.

  4. Containers vs. Components • Container extends Component • Components are things like Button and Checkbox. • Containers contain Components

  5. Hierarchy Sample(from Roberts, Figure 10.4) Frame Panel Panel Panel Panel Label Label Label Text Field Text Field Text Field Scrollbar Scrollbar Scrollbar Panel Button Button Button

  6. Defaults • Panel = FlowLayout • Applet = FlowLayout • Frame = BorderLayout

  7. Constructing a Panel • Construct the panel (new Panel()). • Give the panel a layout manager (setLayout()) • Populate the panel (add()) • Add the panel to its own container (add()).

  8. Component Size and Position • Sizes and positions are merely suggestions, overridden by the LayoutManager. • Each Component has a preferred size, which is “just big enough” to display the component.

  9. FlowLayout Manager • Default type for Panels and Applets. • A lot like a word processor: • Arranges components in horizontal rows. • Components “wrap” to the next line if they don’t fit across. • Honors a component’s preferred size. • Specify in constructor: • FlowLayout.LEFT, FlowLayout.CENTER, FlowLayout.RIGHT

  10. GridLayout Manager • GridLayout( rows, columns ) • Forces a size on a component equal to the size of the cell. • add( component ) - Adds from left to right.

  11. BorderLayout Manager “Center” “North” “West” “East” “South”

  12. BorderLayout Manager • North and South • Honors preferred height • Forces width to width of container • East and West • Honors preferred width • Forces height to height of container. • Remainder of space given to center. • add( component, String )

  13. “Find the Layout Manager” • Refer to 10.4 and find the following Layout Managers: • (1) BorderLayout • (4) GridLayout • (1) FlowLayout

  14. Other Layout Managers • GridBag Layour Manager • Card Layout Manager • No Layout Manager • Create Your Own Layout Manager

  15. References • All Material in this Presentation is heavily based on:Roberts, Simon and Heller, Philip, Java 1.1 Certification Study Guide, 1997: SYBEX™. ISBN: 0-7821-2069-5 • Selected portions from JDK 1.1.6 JavaDoc HTML pages.