// Kenneth J. Goldman // Washington University // 1997, All Rights Reserved // THE AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY // OF THE SOFTWARE, EITHER EXPRESSED OR IMPLIED. THE AUTHORS SHALL NOT BE // LIABLE FOR ANY DAMAGES SUFFERED AS A RESULT OF USING OR MODIFYING // THIS SOFTWARE OR ITS DERIVATIVE. import java.awt.*; public class MyFrame extends Frame { GridBagConstraints gbc; public MyFrame() { setLayout(new GridBagLayout()); gbc = new GridBagConstraints(); addComponents(); pack(); show(); } void addComponents() { add(new TextField("A"),0,0,10,1,100,0,GridBagConstraints.HORIZONTAL); add(new TextArea("B"),0,1,5,8,50,100,GridBagConstraints.BOTH); add(new Button("C"),0,9,5,1,100,0,GridBagConstraints.HORIZONTAL); add(new Picture(100,150,"D"),5,1,5,9,50,100,GridBagConstraints.BOTH); } void add(Component c, int x, int y, int w, int h, int growX, int growY, int fill) { gbc.gridx = x; gbc.gridy = y; gbc.gridwidth = w; gbc.gridheight = h; gbc.weightx = growX; gbc.weighty = growY; gbc.fill = fill; add(c,gbc); } }