All About INTERFACE LayoutManager in Java

A Container in java is a placeholder that contains different GUI attributes(like Frame,Panel,Label etc).Each container object has its own layout manager to place the child components on the screen.Each container object has a Layout manager which is an instance of any class that implements LayoutManager interface.Thus each component(Frame,Panel,Label etc) will have its default layout manager associated with it which may be changed by developer when an instance of that container is created.Each layout manager keeps track of its child components.The layout manager is notified each time one adds a component to the container.Java supports five different Layout Managers.They are as follows:

  1. FlowLayout
  2. BorderLayout
  3. GridLayout
  4. GridBagLayout
  5. CardLayout.
The interface LayoutManager specifies the methods that all the above layout manager must implement.A LayoutManager is responsible for laying out components of a container.

The interface structure of the LayoutManager is given as:

public interface java.awt.LayoutManager {
public abstract void addLayoutComponent(String name,Component comp);
public abstract void layoutContainer(Container target);
public abstract Dimension minimumLayoutSize(Container target);
public abstract Dimension preferredLayoutSize(Container target);
public abstract void removeLayoutComponent(Component comp);
All About INTERFACE LayoutManager in Java All About INTERFACE LayoutManager in Java Reviewed by Animesh Chatterjee on October 23, 2018 Rating: 5

No comments:

Powered by Blogger.