KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jimm > datavision > gui > SectionLayout


1 package jimm.datavision.gui;
2 import java.awt.*;
3
4 /**
5  * A layout manager for {@link SectionWidget}s' contents.
6  *
7  * @author Jim Menard, <a HREF="mailto:jimm@io.com">jimm@io.com</a>
8  */

9 class SectionLayout implements LayoutManager {
10
11 /**
12  * Adds the specified component with the specified name to the layout.
13  *
14  * @param name the component name
15  * @param comp the component to be added
16  */

17 public void addLayoutComponent(String JavaDoc name, Component comp) {
18 }
19
20 /**
21  * Removes the specified component from the layout.
22  *
23  * @param comp the component to be removed
24  */

25 public void removeLayoutComponent(Component comp) {
26 }
27
28 /**
29  * Calculates the preferred size dimensions for the specified panel given
30  * the components in the specified parent container.
31  *
32  * @param parent the component to be laid out
33  * @see #minimumLayoutSize
34  */

35 public Dimension preferredLayoutSize(Container parent) {
36     return minimumLayoutSize(parent);
37 }
38
39 /**
40  * Calculates the minimum size dimensions for the specified panel given the
41  * components in the specified parent container.
42  *
43  * @param parent the component to be laid out
44  * @see #preferredLayoutSize
45  */

46 public Dimension minimumLayoutSize(Container parent) {
47     return parent.getPreferredSize();
48 }
49
50 /**
51  * Lays out the container in the specified panel.
52  *
53  * @param parent the component which needs to be laid out
54  */

55 public void layoutContainer(Container parent) {
56     SectionWidget sw = (SectionWidget)parent;
57     int height = sw.getSectionHeight();
58     Component[] components = parent.getComponents();
59
60     // LHS name label
61
components[0].setBounds(0, 0, SectionWidget.LHS_WIDTH, height);
62
63     // Fields
64
components[1].setBounds(SectionWidget.LHS_WIDTH, 0, sw.getPaperWidth(),
65                 height);
66
67     // Resizer dragger bar
68
components[2].setBounds(0, height, sw.getTotalWidth(),
69                 SectionResizer.HEIGHT);
70 }
71
72 }
73
Popular Tags