All About Class GridBagLayout in AWT in Java

This is an upgraded version of GridLayout.With this we can specify the width,height of the individual grids in a container.The GridBagLayout manager is a flexible layout manager which aligns components horizontally and vertically,without requiring the component to be of the same size.Each GridBagLayout manager uses a rectangular grid of cells,with each component occupying one or more cells(display area).Each component in a GridBagLayout is associated with a set of constraints contained within a GridBagConstraints,instance contained within a GridBagConstraints,instance that specifies how the component is to be laid out within it's display area.The manner in which the GridBagLayout manager places a set of components depends on each components constraints and it's minimum size as well as the preferred size of the component'c container.To use a GridBagLayout effectively,one or more components must have a customized GridBagConstraints objects created for it.
The class structure of GridBagLayout is given as:

public class java.awt.GridBagLayout extends java.lang.Object implements java.awt.LayoutManager{
//member elements 
protected final static int MAXGRIDSIZE;
//MAXGRIDSIZE is 128 the maximum number of grid position both horizontally and vertically that 
//can be laid out by GridBagLayout .
protected final static int MINSIZE;
//MINSIZE is 1.The smallest grid that can be laid out by GridBagLayout .
public GridBagLayout();//creates a GridBagLayout manager
public void addLayoutComponent(String name,Component comp);
public GridBagConstraints getConstraints(Component comp);
protected GridBagConstraints lookupConstraints(Component comp);
public void layoutContainer(Container target);
public Dimension minimumLayoutSize(Container target);
public Dimension preferredLayoutSize(Container target);
public void removeLayoutComponent(Component comp);
public void setConstraints(Component comp,GridBagConstraints constraints)
public String toString();
All About Class GridBagLayout in AWT in Java All About Class GridBagLayout in AWT in Java Reviewed by Animesh Chatterjee on October 23, 2018 Rating: 5

No comments:

Powered by Blogger.