3 import javajs.util.Lst;
5 abstract public class Container extends Component {
7 protected Lst<Component> list;
9 private Component[] cList;
11 protected Container(String type) {
15 public Component getComponent(int i) {
19 public int getComponentCount() {
20 return (list == null ? 0 : list.size());
23 public Component[] getComponents() {
26 return new Component[0];
27 cList = (Component[]) list.toArray();
32 public Component add(Component component) {
33 return addComponent(component);
36 protected Component addComponent(Component component) {
38 list = new Lst<Component>();
39 list.addLast(component);
41 component.parent = this;
45 protected Component insertComponent(Component component, int index) {
47 return addComponent(component);
48 list.add(index, component);
50 component.parent = this;
54 public void remove(int i) {
55 Component c = list.remove(i);
60 public void removeAll() {
62 for (int i = list.size(); --i >= 0;)
63 list.get(i).parent = null;
70 public int getSubcomponentWidth() {
71 return (list != null && list.size() == 1 ? list.get(0).getSubcomponentWidth() : 0);
75 public int getSubcomponentHeight() {
76 return (list != null && list.size() == 1 ? list.get(0).getSubcomponentHeight() : 0);