import java.awt.*;
import javax.swing.*;

public class JRadioButtonExample extends JFrame {

	public JRadioButtonExample() {
		super("JRadioButton example");
		Container cp = getContentPane();

		JRadioButton l = new JRadioButton("Left");
		JRadioButton r = new JRadioButton("Right", true);
		l.setHorizontalTextPosition(AbstractButton.LEFT);
		r.setHorizontalTextPosition(AbstractButton.RIGHT);
		ButtonGroup bg = new ButtonGroup();
		bg.add(l);
		bg.add(r);

		cp.setLayout(new BoxLayout(cp, BoxLayout.X_AXIS));
		cp.add(Box.createRigidArea(new Dimension(40, 50)));
		cp.add(l);
		cp.add(r);
		cp.add(Box.createRigidArea(new Dimension(40, 50)));
	}

	public static void main(String args[]) {
		JRadioButtonExample b = new JRadioButtonExample();
		b.pack();
		b.setVisible(true);
	}
}
