001 /* 002 * Copyright (c) Holger Pfaff - http://pfaff.ws 003 * 004 * This software maybe used for any purpose provided the 005 * above copyright notice is retained. It is supplied as is. 006 * No warranty expressed or implied - Use at your own risk. 007 */ 008 009 import java.awt.*; 010 011 /** 012 * (#)NullLayout.java 013 * @author Holger Pfaff 014 * @version 3.2 19-Mar-2004<br><br> 015 * 016 * A layout to act as an placeholder for the original. 017 * Used in BorderPanel to accomplish minimization 018 * 019 */ 020 021 public class NullLayout implements LayoutManager { 022 023 /** 024 * handle for original layout 025 */ 026 private LayoutManager baseLayout = null; 027 028 /** 029 * The default constructor does - nothing 030 */ 031 public NullLayout() { 032 } 033 034 /** 035 * Move all widgets out of sight! 036 * 037 * @param C our container 038 */ 039 public void layoutContainer(Container C) { 040 Component[] children = C.getComponents(); 041 for(int i = 0; i < children.length; i++) { 042 children[i].setLocation(-999999,-999999); 043 } 044 } 045 046 /** 047 * Layout size is just the border - nothing else 048 * 049 * @param C our container 050 */ 051 public Dimension minimumLayoutSize(Container C) { 052 Insets is = C.getInsets(); 053 return new Dimension(is.left + is.right, is.top + is.bottom); 054 } 055 056 /** 057 * Layout size is just the border - nothing else 058 * 059 * @param C our container 060 */ 061 public Dimension preferredLayoutSize(Container C) { 062 return minimumLayoutSize(C); 063 } 064 065 /** 066 * catch this to tell the original layout that widget was removed 067 * 068 * @param c component to remove 069 */ 070 public void removeLayoutComponent(Component c) { 071 if(baseLayout != null) baseLayout.removeLayoutComponent(c); 072 } 073 074 /** 075 * catch this to tell the original layout that widget was added 076 * 077 * @param s contraints to add component - Layout dependend 078 * @param c component to add 079 */ 080 public void addLayoutComponent(String s, Component c) { 081 if(baseLayout != null) baseLayout.addLayoutComponent(s, c); 082 } 083 084 /** 085 * replace the base layout 086 * 087 * @param l the new base layout 088 */ 089 public void setBaseLayout(LayoutManager l) { 090 baseLayout = l; 091 } 092 093 /** 094 * get current base layout 095 */ 096 public LayoutManager getBaseLayout() { 097 return baseLayout; 098 } 099 }