import java.awt.*; import javax.swing.*; import java.util.*; public class DVDGUI_GridBag extends JFrame { public DVDGUI_GridBag(String title) { super(title); // Set the layout GridBagLayout layout = new GridBagLayout(); GridBagConstraints constraints = new GridBagConstraints(); constraints.insets = new Insets(5, 5, 5, 5); // default spacing setLayout(layout); // This code adds a label JLabel label1 = new JLabel("Title"); constraints.gridx = 0; constraints.gridy = 0; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.fill = GridBagConstraints.BOTH; constraints.weightx = 0; constraints.weighty = 0; layout.setConstraints(label1, constraints); add(label1); JLabel label2 = new JLabel("Year"); // Insert code here JLabel label3 = new JLabel("Length"); // Insert code here JTextField yField = new JTextField("2002"); // Insert code here JTextField lField = new JTextField("93"); // Insert code here JButton button1 = new JButton("Add"); // Insert code here JButton button2 = new JButton("Delete"); // Insert code here JButton button3 = new JButton("Quit"); // Insert code here String[] titles = {"Star Wars", "Java is cool", "Mary Poppins", "The Green Mile"}; JScrollPane theList = new JScrollPane(new JList(titles)); // Insert code here setDefaultCloseOperation(EXIT_ON_CLOSE); setSize(500, 300); } public static void main(String args[]) { new DVDGUI_GridBag("My DVD Collection").setVisible(true); } }