1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package net.wotonomy.ui.swing.components;
20
21 import java.awt.Component;
22 import java.awt.Container;
23 import java.awt.Dimension;
24 import java.awt.LayoutManager;
25 import java.io.Serializable;
26
27 /***
28 * AbsoluteLayout specifies that all components in the
29 * container will be placed according to their size
30 * and their location relative to the container's origin. <br><br>
31 *
32 * You can achieve the same effect by setting a container's
33 * layout manager to null, but this class allows you to subclass
34 * it if you need specific control or functionality.
35 *
36 * @author michael@mpowers.net
37 * @author $Author: cgruber $
38 * @version $Revision: 904 $
39 */
40 public class AbsoluteLayout implements LayoutManager, Serializable
41 {
42 public void addLayoutComponent(String name,
43 Component comp)
44 {
45 }
46
47 public void removeLayoutComponent(Component comp)
48 {
49 }
50
51 public Dimension preferredLayoutSize(Container parent)
52 {
53 return minimumLayoutSize( parent );
54 }
55
56 public Dimension minimumLayoutSize(Container parent)
57 {
58 int width = 0;
59 int height = 0;
60
61 Component[] c = parent.getComponents();
62 for ( int i = 0; i < c.length; i++ )
63 {
64 width = Math.max( width, c[i].getLocation().x + c[i].getBounds().width );
65 height = Math.max( height, c[i].getLocation().y + c[i].getBounds().height );
66 }
67
68 return new Dimension( width, height );
69 }
70
71 public void layoutContainer(Container parent)
72 {
73 }
74 }