768 Graphical User Interface Components: Part 2 Chapter (Web site management)
768 Graphical User Interface Components: Part 2 Chapter 13 33 34 // create strut and add buttons to boxes[ 1 ] 35 for ( int count = 0; count < SIZE; count++ ) { 36 boxes[ 1 ].add( Box.createVerticalStrut( 25 ) ); 37 boxes[ 1 ].add( new JButton( "boxes[1]: " + count ) ); 38 } 39 40 // create horizontal glue and add buttons to boxes[ 2 ] 41 for ( int count = 0; count < SIZE; count++ ) { 42 boxes[ 2 ].add( Box.createHorizontalGlue() ); 43 boxes[ 2 ].add( new JButton( "boxes[2]: " + count ) ); 44 } 45 46 // create rigid area and add buttons to boxes[ 3 ] 47 for ( int count = 0; count < SIZE; count++ ) { 48 boxes[ 3 ].add( 49 Box.createRigidArea( new Dimension( 12, 8 ) ) ); 50 boxes[ 3 ].add( new JButton( "boxes[3]: " + count ) ); 51 } 52 53 // create vertical glue and add buttons to panel 54 JPanel panel = new JPanel(); 55 panel.setLayout( 56 new BoxLayout( panel, BoxLayout.Y_AXIS ) ); 57 58 for ( int count = 0; count < SIZE; count++ ) { 59 panel.add( Box.createGlue() ); 60 panel.add( new JButton( "panel: " + count ) ); 61 } 62 63 // place panels on frame 64 container.add( boxes[ 0 ], BorderLayout.NORTH ); 65 container.add( boxes[ 1 ], BorderLayout.EAST ); 66 container.add( boxes[ 2 ], BorderLayout.SOUTH ); 67 container.add( boxes[ 3 ], BorderLayout.WEST ); 68 container.add( panel, BorderLayout.CENTER ); 69 70 setSize( 350, 300 ); 71 setVisible( true ); 72 73 } // end constructor 74 75 // execute application 76 public static void main( String args[] ) 77 { 78 BoxLayoutDemo application = new BoxLayoutDemo(); 79 80 application.setDefaultCloseOperation( 81 JFrame.EXIT_ON_CLOSE ); 82 } 83 84 } // end class BoxLayoutDemo Fig. 13.15 Demonstrating the BoxLayoutlayout manager (part 2 of 3).
Note: If you are looking for high quality webhost to host and run your jsp application check Vision jsp web hosting services