/[classpath]/classpath/javax/swing/BoxLayout.java
ViewVC logotype

Diff of /classpath/javax/swing/BoxLayout.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.6 by mark, Sat Jul 31 22:25:17 2004 UTC revision 1.6.2.1 by gnu_andrew, Sun Mar 13 14:38:43 2005 UTC
# Line 42  import java.awt.Component; Line 42  import java.awt.Component;
42  import java.awt.ComponentOrientation;  import java.awt.ComponentOrientation;
43  import java.awt.Container;  import java.awt.Container;
44  import java.awt.Dimension;  import java.awt.Dimension;
45    import java.awt.Insets;
46  import java.awt.LayoutManager2;  import java.awt.LayoutManager2;
47  import java.io.Serializable;  import java.io.Serializable;
48    
# Line 146  public class BoxLayout implements Layout Line 147  public class BoxLayout implements Layout
147      if (parent != container)      if (parent != container)
148        throw new AWTError("invalid parent");        throw new AWTError("invalid parent");
149    
150      int x = 0;      Insets insets = parent.getInsets();
151      int y = 0;      int x = insets.left + insets.right;
152        int y = insets.bottom + insets.top;
153    
154      Component[] children = parent.getComponents();      Component[] children = parent.getComponents();
155    
# Line 191  public class BoxLayout implements Layout Line 193  public class BoxLayout implements Layout
193      if (parent != container)      if (parent != container)
194        throw new AWTError("invalid parent");        throw new AWTError("invalid parent");
195    
196      int x = 0;      Insets insets = parent.getInsets();
197      int y = 0;      int x = insets.left + insets.right;
198        int y = insets.bottom + insets.top;
199    
200      Component[] children = parent.getComponents();      Component[] children = parent.getComponents();
201    
# Line 235  public class BoxLayout implements Layout Line 238  public class BoxLayout implements Layout
238        throw new AWTError("invalid parent");        throw new AWTError("invalid parent");
239    
240      Dimension size = parent.getSize();      Dimension size = parent.getSize();
241        Insets insets = parent.getInsets();
242        Dimension innerSize = new Dimension(size.width - insets.left
243                                            - insets.right, size.height
244                                            - insets.bottom - insets.top);
245      Component[] children = parent.getComponents();      Component[] children = parent.getComponents();
246    
247      if (isHorizontalIn(parent))      if (isHorizontalIn(parent))
248        {        {
249          int x = 0;          int x = insets.left;
250          for (int index = 0; index < children.length; index++)          for (int index = 0; index < children.length; index++)
251            {            {
252              Component comp = children[index];              Component comp = children[index];
253              Dimension sz = comp.getPreferredSize();              Dimension sz = comp.getPreferredSize();
254              int width = sz.width;              int width = sz.width;
255              int height = sz.height;              int height = sz.height;
256              int cy = 0;              int cy = insets.top;
257              if (height > size.height)              if (height > innerSize.height)
258                {                {
259                  height = size.height;                  height = innerSize.height;
260                }                }
261              else              else
262                {                {
263                  cy = (int) ((size.height - height) * comp.getAlignmentY());                  cy = (int) ((innerSize.height - height)
264                                * comp.getAlignmentY());
265                }                }
266                            
267              comp.setSize(width, height);              comp.setSize(width, height);
# Line 264  public class BoxLayout implements Layout Line 271  public class BoxLayout implements Layout
271        }        }
272      else      else
273        {        {
274          int y = 0;                  int y = insets.top;        
275          for (int index = 0; index < children.length; index++)          for (int index = 0; index < children.length; index++)
276            {            {
277              Component comp = children[index];              Component comp = children[index];
278              Dimension sz = comp.getPreferredSize();              Dimension sz = comp.getPreferredSize();
279              int width = sz.width;              int width = sz.width;
280              int height = sz.height;              int height = sz.height;
281              int cx = 0;              int cx = insets.left;
282              if (width > size.width)              if (width > innerSize.width)
283                {                {
284                  width = size.width;                  width = innerSize.width;
285                }                }
286              else              else
287                {                {
288                  cx = (int) ((size.width - width) * comp.getAlignmentX());                  cx = (int) ((innerSize.width - width) * comp.getAlignmentX());
289                }                }
290                            
291              comp.setSize(width, height);              comp.setSize(width, height);
# Line 352  public class BoxLayout implements Layout Line 359  public class BoxLayout implements Layout
359      if (parent != container)      if (parent != container)
360        throw new AWTError("invalid parent");        throw new AWTError("invalid parent");
361    
362      int x = 0;      Insets insets = parent.getInsets();
363      int y = 0;      int x = insets.left + insets.right;
364        int y = insets.top + insets.bottom;
365    
366      Component[] children = parent.getComponents();      Component[] children = parent.getComponents();
367    

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.6.2.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26