/* Name: Chris Johnson johnson@dcs.gla.ac.uk Last modified: 26/10/98 Description: provides some "convenience" methods by packaging away multiple calls to add, position and size the components of a GridBagLayout. From G.W. Rouse's An Introduction to Data Structures and Algorithms with Java, Prentice Hall, Hemel Hemstead, 1998. pp 65-78. */ package uk.ac.gla.dcs.johnson; import java.awt.*; public class NewGridBagLayout extends GridBagLayout { private GridBagConstraints constraints; public NewGridBagLayout() { super(); constraints = new GridBagConstraints(); } public void setRareConstraints(int anchor, int fill, Insets insets, int ipadx, int ipady, double weightx, double weighty) { constraints.anchor = anchor; constraints.fill = fill; constraints.insets = insets; constraints.ipadx = ipadx; constraints.ipady = ipady; constraints.weightx= weightx; constraints.weighty = weighty; } public void setPositionSizeAdd(Component control, Container parent, int gridx, int gridy, int gridwidth, int gridheight) // without this method the programmer would have to issue six calls rather than one // to set all of the constraints and add the component { constraints.gridx = gridx; constraints.gridy = gridy; constraints.gridwidth = gridwidth; constraints.gridheight = gridheight; setConstraints(control, constraints); parent.add(control); } }