1 27 package org.htmlparser.parserapplications.filterbuilder.layouts; 28 29 import java.awt.*; 30 import java.io.*; 31 32 38 public class VerticalLayoutManager 39 implements 40 LayoutManager2, 41 Serializable 42 { 43 46 public VerticalLayoutManager () 47 { 48 } 49 50 56 public Dimension minimumLayoutSize (Container target) 57 { 58 return (preferredLayoutSize (target)); 59 } 60 61 67 public Dimension preferredLayoutSize (Container target) 68 { 69 int count; 70 Component component; 71 Dimension dimension; 72 Insets insets; 73 Dimension ret; 74 75 synchronized (target.getTreeLock ()) 76 { 77 ret = new Dimension (0, 0); 79 count = target.getComponentCount (); 80 for (int i = 0 ; i < count ; i++) 81 { 82 component = target.getComponent (i); 83 if (component.isVisible ()) 84 { 85 dimension = component.getPreferredSize (); 86 ret.width = Math.max (ret.width, dimension.width); 87 ret.height += dimension.height; 88 } 89 } 90 insets = target.getInsets (); 91 ret.width += insets.left + insets.right; 92 ret.height += insets.top + insets.bottom; 93 } 94 95 return (ret); 96 } 97 98 105 public Dimension maximumLayoutSize (Container target) 106 { 107 return (preferredLayoutSize (target)); 108 } 109 110 114 120 public void addLayoutComponent (String name, Component comp) 121 { 122 } 123 124 128 public void removeLayoutComponent (Component comp) 129 { 130 } 131 132 136 public void layoutContainer (Container target) 137 { 138 Insets insets; 139 int x; 140 int y; 141 int count; 142 int width; 143 Component component; 144 Dimension dimension; 145 146 synchronized (target.getTreeLock ()) 147 { 148 insets = target.getInsets (); 149 x = insets.left; 150 y = insets.top; 151 count = target.getComponentCount (); 152 width = 0; 153 for (int i = 0 ; i < count ; i++) 154 { 155 component = target.getComponent (i); 156 if (component.isVisible ()) 157 { 158 dimension = component.getPreferredSize (); 159 width = Math.max (width, dimension.width); 160 component.setSize (dimension.width, dimension.height); 161 component.setLocation (x, y); 162 y += dimension.height; 163 } 164 } 165 for (int i = 0 ; i < count ; i++) 167 { 168 component = target.getComponent (i); 169 if (component.isVisible ()) 170 { 171 dimension = component.getSize (); 172 dimension.width = width; 173 component.setSize (dimension.width, dimension.height); 174 } 175 } 176 } 177 } 178 179 183 189 public void addLayoutComponent (Component comp, Object constraints) 190 { 191 } 192 193 201 public float getLayoutAlignmentX (Container target) 202 { 203 return (0.0f); 204 } 205 206 214 public float getLayoutAlignmentY (Container target) 215 { 216 return (0.0f); 217 } 218 219 224 public void invalidateLayout (Container target) 225 { 226 } 227 } 228 | Popular Tags |