import java.awt.Button; import java.awt.Panel; import java.awt.GridBagLayout; import java.awt.GridBagConstraints; import java.applet.Applet; public class gridBagLayout extends Applet { Button new_button, edit_button, delete_button; GridBagLayout gridbag; GridBagConstraints c; public void init() { int RELA = GridBagConstraints.RELATIVE; int REMN = GridBagConstraints.REMAINDER; gridbag = new GridBagLayout(); c = new GridBagConstraints(); setLayout(gridbag); c.fill = GridBagConstraints.BOTH; // NAME WEIGHTX WEIGHTY GRIDW GRIDH make_button("Name", 0.0, 0.0, 1, 1); make_button("NameField", 1.0, 0.0, REMN, 1); make_button("Title", 0.0, 0.0, 1, 1); make_button("TitleField", 1.0, 0.0, REMN, 1); make_button("Descr", 0.0, 0.0, 1, 1); make_button("DescrField", 1.0, 0.0, REMN, 1); make_button("Company", 0.0, 0.0, 1, 1); make_button("CompanyField", 1.0, 0.0, REMN, 1); make_button("Email", 0.0, 0.0, 1, 1); make_button("EmailField", 1.0, 0.0, REMN, 1); make_button("Mailstop", 0.0, 0.0, 1, 1); make_button("MailstopField", 1.0, 0.0, REMN, 1); make_button("Street", 0.0, 0.0, 1, 1); make_button("StreetField", 1.0, 0.0, REMN, 1); make_button("City", 0.0, 0.0, 1, 1); make_button("CityField", 1.0, 0.0, 4, 1); make_button("State", 0.0, 0.0, 1, 1); make_button("StateField", 0.0, 0.0, 1, 1); make_button("Zip", 0.0, 0.0, 1, 1); make_button("ZipField", 0.0, 0.0, REMN, 1); make_button("Phone", 0.0, 0.0, 1, 1); make_button("PhoneField", 0.0, 0.0, REMN, 1); make_button("Fax", 0.0, 0.0, 1, 1); make_button("FaxField", 0.0, 0.0, REMN, 1); make_button("Notes", 0.0, 1.0, 1, 1); make_button("NotesField", 0.0, 0.0, REMN, 1); make_button("New", 0.0, 0.0, 1, 1); make_button("Edit", 0.0, 0.0, 1, 1); make_button("Delete", 0.0, 0.0, 1, 1); show(); } void make_button(String name, double weightx, double weighty, int gridweight, int gridheight) { c.weightx = weightx; c.weighty = weighty; c.gridwidth = gridweight; c.gridheight = gridheight; Button button = new Button(name); gridbag.setConstraints(button, c); add(button); } }