TestGridBagLayout5.java
Select all
/* TestGridBagLayout5.java CIS 260 2/22/2006 David Klick Demonstration of GridBagLayout using weightx and weighty. The effect is most noticeable as the frame is made wider. */ import java.awt.*; import java.awt.event.*; import javax.swing.*; public class TestGridBagLayout5 extends JFrame { public static void main(String[] args) { TestGridBagLayout5 app = new TestGridBagLayout5(); 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(); for (i=0; i