Abstract Interface LayoutManager in Java

0
22
Spread the love
  • 28
  • 34
  • 56
  • 35
  •  
  •  
  •  
  • 12
  •  
  •  
    165
    Shares

Abstract Interface LayoutManager in Java

LayoutManager is an interface that defines the responsibilities of an object that wants to lay out Components to the display in a Container.

The structure of the abstract interface LayoutManager is given by

public abstract interface java.awt.LayoutManager {
// Interface Methods
public abstract void addLayoutComponent (String name,
Component component);
public abstract void layoutContainer (Container target);
public abstract Dimension minimumLayoutSize (Container target);
public abstract Dimension preferredLayoutSize (Container target);
public abstract void removeLayoutComponent (Component component);
}

The details of the class structure are given as follows:

public abstract void addLayoutComponent (String name,Component component);

public abstract void addLayoutComponent (String name,Component component) method adds an object to a container when Container.add(String, Component) is called.

Parameter
name – Name of component to add.
component – Actual component being added.

public abstract void layoutContainer (Container target);

public abstract void layoutContainer (Container target) method is called when target needs to be redrawn.

Parameter
target – The container who needs to be redrawn.

public abstract Dimension minimumLayoutSize (Container target);

public abstract Dimension minimumLayoutSize (Container target) method is called when the minimum size of the target container needs to be calculated.

This method returns the minimum Dimension of the container target

Parameter
target – The container whose size needs to be calculated.

public abstract Dimension preferredLayoutSize (Container target);

public abstract Dimension preferredLayoutSize (Container target) method is called when the preferred size of the target container needs to be calculated.

This method returns the preferred Dimension of the container target

Parameter
target – The container whose size needs to be calculated.

public abstract void removeLayoutComponent (Component component);

public abstract void removeLayoutComponent (Component component) method remove a component from thelayout when Container.remove(Component) is called.

Parameter
component – Component to no longer track.

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
  • 28
  • 34
  • 56
  • 35
  •  
  •  
  •  
  • 12
  •  
  •  
    165
    Shares

LEAVE A REPLY

Please enter your comment!
Please enter your name here