Java Code




/** Example showing use of JRadioButton
  * @author : E.S.Boese (c) Fall 2005
  */
import javax.swing.*;
import java.awt.*;
public class JRadioButtonEx extends JApplet
{
   JRadioButton jb1, jb2, jb3;
   ButtonGroup group;

   public void init( )
   {
		setLayout( new FlowLayout( )   );

    	jb1 = new JRadioButton( "red" );
    	jb2 = new JRadioButton( "blue" );
    	jb3 = new JRadioButton( "pink" );
    	group = new ButtonGroup( );

		group.add( jb1 );
		group.add( jb2 );
		group.add( jb3 );

		add( jb1 );
		add( jb2 );
		add( jb3 );
  }
}

Back to Code Examples
©2006- by E.S.Boese. All Rights Reserved