1 package jimm.datavision.gui; 2 import java.awt.*; 3 4 9 class DesignWinLayout implements LayoutManager { 10 11 17 public void addLayoutComponent(String name, Component comp) { 18 } 19 20 25 public void removeLayoutComponent(Component comp) { 26 } 27 28 35 public Dimension preferredLayoutSize(Container parent) { 36 return minimumLayoutSize(parent); 37 } 38 39 46 public Dimension minimumLayoutSize(Container parent) { 47 int width = 0; 48 int height = 0; 49 Component[] components = parent.getComponents(); 50 for (int i = 0; i < components.length; ++i) { 51 Component c = components[i]; 52 if (c instanceof SectionWidget) { Dimension dim = c.getPreferredSize(); 54 if (width == 0) width = dim.width; 55 height += dim.height; 56 } 57 } 58 return new Dimension(width, height); 59 } 60 61 66 public void layoutContainer(Container parent) { 67 int y = 0; 68 Component[] components = parent.getComponents(); 69 for (int i = 0; i < components.length; ++i) { 70 Component c = components[i]; 71 if (c instanceof SectionWidget) { Dimension dim = c.getPreferredSize(); 73 c.setBounds(0, y, dim.width, dim.height); 74 y += dim.height; 75 } 76 } 77 } 78 79 } 80 | Popular Tags |