Introduction
Description
Methods public int countComponents() and public int getComponentCount () : These methods are used to get the number of components in the container.
public Component[] getComponents() : An array of components in the container can be returned using this method. When made any changes to the components, the changes can be seen on the c-screen.
public Component getComponent(int position) : This method returns the component by pointing to the given position. If the component position is incorrect, the compiler throws ArrayIndexOutOfBoundException.
Methods public Component add(Component component, int position) : This method is used to add a component at the given position. IllegalArgumentException is thrown if the position is invalid.
public Component add (Component component) : This method adds the component but as the last object of the container.
public void add (Component component, Object constraints) : This method is used in layouts, which asks for additional info to accept the components.
Methods public void remove (int index) : This method removes the component following the index provided. If the index is invalid, compiler throws IllegalArgumentException.
public void remove (Component component): This method removes the component in the container without any index or position. If there are nested containers, it simply ignores.
public void removeAll(): All the components are deleted at a time from the container.
Examples
Key Points