package panels;
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
/*
Insert a component to the Panel with the values for the gridbag constraints
*/
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);
}
/*
paint the ancestoral containers
Repaint this to root container
*/
public void paintAncestors(){
Component C=this;
while(C.getParent()!=null){
C.repaint();
C=C.getParent();
}
}
}