X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=src%2Fjavajs%2Fawt%2FContainer.java;h=7ef6e905503f12d35e25c825a8a2f67d794524e5;hp=a7346368ff40a21e2d8bab8e068617fe648914d0;hb=b9b7a352eee79b7764c3b09c9d19663075061d8c;hpb=8ffd05b3abe52c0b6b79b011c0966361f82d5fe6 diff --git a/src/javajs/awt/Container.java b/src/javajs/awt/Container.java index a734636..7ef6e90 100644 --- a/src/javajs/awt/Container.java +++ b/src/javajs/awt/Container.java @@ -1,79 +1,79 @@ -package javajs.awt; - -import javajs.util.Lst; - -abstract public class Container extends Component { - - protected Lst list; - - private Component[] cList; - - protected Container(String type) { - super(type); - } - - public Component getComponent(int i) { - return list.get(i); - } - - public int getComponentCount() { - return (list == null ? 0 : list.size()); - } - - public Component[] getComponents() { - if (cList == null) { - if (list == null) - return new Component[0]; - cList = (Component[]) list.toArray(); - } - return cList; - } - - public Component add(Component component) { - return addComponent(component); - } - - protected Component addComponent(Component component) { - if (list == null) - list = new Lst(); - list.addLast(component); - cList = null; - component.parent = this; - return component; - } - - protected Component insertComponent(Component component, int index) { - if (list == null) - return addComponent(component); - list.add(index, component); - cList = null; - component.parent = this; - return component; - } - - public void remove(int i) { - Component c = list.remove(i); - c.parent = null; - cList = null; - } - - public void removeAll() { - if (list != null) { - for (int i = list.size(); --i >= 0;) - list.get(i).parent = null; - list.clear(); - } - cList = null; - } - - @Override - public int getSubcomponentWidth() { - return (list != null && list.size() == 1 ? list.get(0).getSubcomponentWidth() : 0); - } - - @Override - public int getSubcomponentHeight() { - return (list != null && list.size() == 1 ? list.get(0).getSubcomponentHeight() : 0); - } - -} +package javajs.awt; + +import javajs.util.Lst; + +abstract public class Container extends Component { + + protected Lst list; + + private Component[] cList; + + protected Container(String type) { + super(type); + } + + public Component getComponent(int i) { + return list.get(i); + } + + public int getComponentCount() { + return (list == null ? 0 : list.size()); + } + + public Component[] getComponents() { + if (cList == null) { + if (list == null) + return new Component[0]; + cList = (Component[]) list.toArray(); + } + return cList; + } + + public Component add(Component component) { + return addComponent(component); + } + + protected Component addComponent(Component component) { + if (list == null) + list = new Lst(); + list.addLast(component); + cList = null; + component.parent = this; + return component; + } + + protected Component insertComponent(Component component, int index) { + if (list == null) + return addComponent(component); + list.add(index, component); + cList = null; + component.parent = this; + return component; + } + + public void remove(int i) { + Component c = list.remove(i); + c.parent = null; + cList = null; + } + + public void removeAll() { + if (list != null) { + for (int i = list.size(); --i >= 0;) + list.get(i).parent = null; + list.clear(); + } + cList = null; + } + + @Override + public int getSubcomponentWidth() { + return (list != null && list.size() == 1 ? list.get(0).getSubcomponentWidth() : 0); + } + + @Override + public int getSubcomponentHeight() { + return (list != null && list.size() == 1 ? list.get(0).getSubcomponentHeight() : 0); + } + +}