... Fig. 35.17 Test class for BoxLayoutFrame.


1   // Fig. 22.17: BoxLayoutDemo.java
2   // Demonstrating BoxLayout.
3   import javax.swing.JFrame;
4
5   public class BoxLayoutDemo
6   {
7      public static void main(String[] args)
8      {
9         BoxLayoutFrame boxLayoutFrame = new BoxLayoutFrame();
10           boxLayoutFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
11           boxLayoutFrame.setSize(400, 220);
12           boxLayoutFrame.setVisible(true);
13      }
14   } // end class BoxLayoutDemo
The corresponding output windows are also displayed.

Creating Box Containers

Lines 19–22 create Box containers. References horizontal1 and horizontal2 are initialized with static Box method createHorizontalBox, which returns a ...

Get Java How to Program, Early Objects, 11th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.