KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > swingwt > awt > FillLayout


1 /*
2  * FillLayout.java
3  *
4  * Created on March 22, 2004, 2:34 PM
5  */

6
7 package swingwt.awt;
8
9 /**
10  * Simple layout manager that allows one component and it
11  * fills the whole container.
12  *
13  * @author Robin Rawson-Tetley
14  */

15 public class FillLayout implements LayoutManager {
16
17     protected Component theComponent = null;
18     public void addLayoutComponent(String JavaDoc name, Component comp) {
19         theComponent = comp;
20     }
21     public void removeLayoutComponent(Component comp) {
22         if (comp == theComponent)
23             theComponent = null;
24     }
25     public Dimension preferredLayoutSize(Container parent) {
26         if (theComponent == null) return new Dimension(0, 0);
27         return theComponent.getPreferredSize();
28     }
29     public Dimension minimumLayoutSize(Container parent) {
30         return preferredLayoutSize(parent);
31     }
32     public void layoutContainer(Container parent) {
33         if (theComponent == null) return;
34         theComponent.setBounds(0, 0, parent.getWidth(), parent.getHeight());
35     }
36     
37 }
38
Popular Tags