760 Graphical User Interface Components: Part 2 (Yahoo web hosting) Chapter
Friday, April 27th, 2007760 Graphical User Interface Components: Part 2 Chapter 13 44 45 // attach NORTH panel to content pane 46 container.add( northPanel, BorderLayout.NORTH ); 47 48 // create array for radio buttons 49 radio = new JRadioButton[ strings.length ]; 50 51 // set up panel for SOUTH of BorderLayout 52 JPanel southPanel = new JPanel(); 53 southPanel.setLayout( 54 new GridLayout( 1, radio.length ) ); 55 56 // set up radio buttons for SOUTH panel 57 group = new ButtonGroup(); 58 ItemHandler handler = new ItemHandler(); 59 60 for ( int count = 0; count < radio.length; count++ ) { 61 radio[ count ] = new JRadioButton( strings[ count ] ); 62 radio[ count ].addItemListener( handler ); 63 group.add( radio[ count ] ); 64 southPanel.add( radio[ count ] ); 65 } 66 67 // attach SOUTH panel to content pane 68 container.add( southPanel, BorderLayout.SOUTH ); 69 70 // get installed look-and-feel information 71 looks = UIManager.getInstalledLookAndFeels(); 72 73 setSize( 300, 200 ); 74 setVisible( true ); 75 76 radio[ 0 ].setSelected( true ); 77 } 78 79 // use UIManager to change look-and-feel of GUI 80 private void changeTheLookAndFeel( int value ) 81 { 82 // change look and feel 83 try { 84 UIManager.setLookAndFeel( 85 looks[ value ].getClassName() ); 86 SwingUtilities.updateComponentTreeUI( this ); 87 } 88 89 // process problems changing look and feel 90 catch ( Exception exception ) { 91 exception.printStackTrace(); 92 } 93 } 94 Fig. 13.12 Fig. 13.12 Changing the look-and-feel of a Swing-based GUI (part 2 of 3).
Note: In case you are looking for affordable webhost to host and run your servlet application check Vision servlet hosting services