Mega Code Archive

 
Categories / Java / Swing JFC
 

A test of the box layout manager using the Box utility class 2

/* Java Swing, 2nd Edition By Marc Loy, Robert Eckstein, Dave Wood, James Elliott, Brian Cole ISBN: 0-596-00408-7 Publisher: O'Reilly  */ // HBoxWithGlue.java //A quick test of the box layout manager using the Box utility class. // import java.awt.Button; import javax.swing.Box; import javax.swing.JFrame; public class HBoxWithGlue extends JFrame {   public HBoxWithGlue() {     super("Box & Glue Frame");     setSize(350, 100);     Box box = Box.createHorizontalBox();     setContentPane(box);     box.add(Box.createHorizontalGlue());     for (int i = 0; i < 3; i++) {       Button b = new Button("B" + i);       box.add(b);     }     box.add(Box.createHorizontalGlue());     setDefaultCloseOperation(EXIT_ON_CLOSE);     setVisible(true);   }   public static void main(String args[]) {     HBoxWithGlue bt = new HBoxWithGlue();   } }