1 6 7 package swingwt.awt; 8 9 15 public class FillLayout implements LayoutManager { 16 17 protected Component theComponent = null; 18 public void addLayoutComponent(String name, Component comp) { 19 theComponent = comp; 20 } 21 public void removeLayoutComponent(Component comp) { 22 if (comp == theComponent) 23 theComponent = null; 24 } 25 public Dimension preferredLayoutSize(Container parent) { 26 if (theComponent == null) return new Dimension(0, 0); 27 return theComponent.getPreferredSize(); 28 } 29 public Dimension minimumLayoutSize(Container parent) { 30 return preferredLayoutSize(parent); 31 } 32 public void layoutContainer(Container parent) { 33 if (theComponent == null) return; 34 theComponent.setBounds(0, 0, parent.getWidth(), parent.getHeight()); 35 } 36 37 } 38 | Popular Tags |