Container Class In Java

0
62
Spread the love
  • 24
  • 34
  • 12
  • 23
  •  
  •  
  •  
  • 12
  •  
  •  
    105
    Shares

Container Class In Java
Container Class In Java

Container Class In Java:

Container class can hold other components in Java application. It implements the Component class to hold or contain these other components.We need to use its sub classes like Panel,Frame,Dialog etc to hold components. We can not directly instantiate Container class.The Container , once created,can hold objects and position them using LayoutManager.

The structure of Container Class is given as:


public abstract class java.awt.Container extends
                      java.awt.Component {
// Constructor
protected Container();
// Methods
public Component add(Component comp);
public Component add(String name, Component comp);
public Component add(Component comp, int index);
public void add(Component comp, Object constraints);
public void add(Component comp, Object constraints, int index);
public void addContainerListener(ContainerListener l);
public void addNotify(); 
public int countComponents();
public void deliverEvent(Event e); 
public void doLayout(); 
public float getAlignmentX(); 
public float getAlignmentY(); 
public Component getComponent(int n);
public Component getComponentAt(int x, int y); 
public Component getComponentAt(Point p); 
public int getComponentCount();
public Component[] getComponents();
public Insets getInsets();
public LayoutManager getLayout();
public Dimension getMaximumSize(); 
public Dimension getMinimumSize(); 
public Dimension getPreferredSize(); 
public Insets insets();
public void invalidate(); 
public boolean isAncestorOf(Component c);
public void layout(); 
public void list(PrintStream out, int indent); 
public void list(PrintWriter out, int indent); 
public Component locate(int x, int y); 
public Dimension minimumSize(); 
public void paint(Graphics g); 
public void paintComponents(Graphics g);
public Dimension preferredSize(); 
public void print(Graphics g); 
public void printComponents(Graphics g);
public void remove(int index);
public void remove(Component comp);
public void removeAll();
public void removeContainerListener(ContainerListener l);
public void removeNotify(); 
public void setLayout(LayoutManager mgr);
public void validate(); 
protected void addImpl(Component comp, Object constraints, int index);
protected String paramString(); 
protected void processContainerEvent(ContainerEvent e);
protected void processEvent(AWTEvent e); 
protected void validateTree();
}
 
Don't miss out!
Subscribe To Newsletter

Receive top technical news, lesson ideas, travel tips and more!

Invalid email address
Give it a try. You can unsubscribe at any time.

Spread the love
  • 24
  • 34
  • 12
  • 23
  •  
  •  
  •  
  • 12
  •  
  •  
    105
    Shares

LEAVE A REPLY

Please enter your comment!
Please enter your name here