1 29 30 package nextapp.echo2.app; 31 32 43 public class ContentPane extends Component 44 implements Pane, PaneContainer { 45 46 private static final Extent PX_0 = new Extent(0); 47 private static final Extent SCROLL_BOTTOM = new Extent(-1); 48 49 public static final String PROPERTY_BACKGROUND_IMAGE = "backgroundImage"; 50 public static final String PROPERTY_HORIZONTAL_SCROLL = "horizontalScroll"; 51 public static final String PROPERTY_INSETS = "insets"; 52 public static final String PROPERTY_VERTICAL_SCROLL = "verticalScroll"; 53 54 57 public ContentPane() { 58 super(); 59 } 60 61 66 public FillImage getBackgroundImage() { 67 return (FillImage) getProperty(PROPERTY_BACKGROUND_IMAGE); 68 } 69 70 75 public Extent getHorizontalScroll() { 76 return (Extent) getProperty(PROPERTY_HORIZONTAL_SCROLL); 77 } 78 79 88 public Insets getInsets() { 89 return (Insets) getProperty(PROPERTY_INSETS); 90 } 91 92 97 public Extent getVerticalScroll() { 98 return (Extent) getProperty(PROPERTY_VERTICAL_SCROLL); 99 } 100 101 104 public boolean isValidChild(Component child) { 105 if (child instanceof FloatingPane) { 106 return true; 108 } 109 110 int componentCount = getComponentCount(); 112 for (int i = 0; i < componentCount; ++i) { 113 if (!(getComponent(i) instanceof FloatingPane)) { 114 return false; 115 } 116 } 117 118 return true; 119 } 120 121 124 public boolean isValidParent(Component parent) { 125 return parent instanceof PaneContainer || parent instanceof Window; 126 } 127 128 131 public void processInput(String inputName, Object inputValue) { 132 if (PROPERTY_HORIZONTAL_SCROLL.equals(inputName)) { 133 setHorizontalScroll((Extent) inputValue); 134 } else if (PROPERTY_VERTICAL_SCROLL.equals(inputName)) { 135 setVerticalScroll((Extent) inputValue); 136 } 137 } 138 139 144 public void setBackgroundImage(FillImage newValue) { 145 setProperty(PROPERTY_BACKGROUND_IMAGE, newValue); 146 } 147 148 156 public void setHorizontalScroll(Extent newValue) { 157 setProperty(PROPERTY_HORIZONTAL_SCROLL, newValue); 158 } 159 160 169 public void setInsets(Insets newValue) { 170 setProperty(PROPERTY_INSETS, newValue); 171 } 172 173 181 public void setVerticalScroll(Extent newValue) { 182 if (SCROLL_BOTTOM.equals(newValue)) { 183 setProperty(PROPERTY_VERTICAL_SCROLL, PX_0); 184 } 185 setProperty(PROPERTY_VERTICAL_SCROLL, newValue); 186 } 187 } 188 | Popular Tags |