TestGridBagLayout2.java
Select all
/* TestGridBagLayout2.java CIS 260 2/22/2006 David Klick Demonstration of GridBagLayout with insets to put space between components. */ import java.awt.*; import java.awt.event.*; import javax.swing.*; public class TestGridBagLayout2 extends JFrame { public static void main(String[] args) { TestGridBagLayout2 app = new TestGridBagLayout2(); app.setDefaultCloseOperation(EXIT_ON_CLOSE); app.init(); } public void init() { int i; JButton btn[] = new JButton[4]; Container c = getContentPane(); c.setLayout(new GridBagLayout()); GridBagConstraints gb = new GridBagConstraints(); gb.insets = new Insets(5, 5, 5, 5); for (i=0; i