Package

Source Code of GBPane

import javax.swing.JPanel;

import java.awt.Component;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;

public class GBPane extends JPanel {

  private GridBagLayout GB;
 
  //Constructors
  public GBPane(){
    setLayout(GB=new GridBagLayout());
  }
 
  //Methods
  public void addComponent(Component component, int gridx, int gridy,
         int gridwidth, int gridheight, int weightx, int weighty, int fill,
         int anchor) {
         GridBagConstraints constraints = new GridBagConstraints();
         constraints.gridx = gridx;
         constraints.gridy = gridy;
         constraints.gridwidth = gridwidth;
         constraints.gridheight = gridheight;
         constraints.weightx = weightx;
         constraints.weighty = weighty;
         constraints.fill = fill;
         constraints.anchor = anchor;
         GB.setConstraints(component, constraints);
         add(component);
     }
  public void paintAncestors(){
    Component C=this;
   
    while(C.getParent()!=null){
      C.repaint();
      C=C.getParent();
    }
  }
}
TOP

Related Classes of GBPane

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.