Adding a radiobutton to a JToolBar

Main.java:

import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
 
public class Main extends JFrame
{
   public Main()
   {
      JToolBar toolBar = new JToolBar();
 
      JRadioButton gifButton = new JRadioButton("GIF", false);
      JRadioButton jpgButton = new JRadioButton("JPG", false);
      JRadioButton tiffButton = new JRadioButton("TIFF", false);
 
      ButtonGroup group = new ButtonGroup();
      group.add(gifButton);
      group.add(jpgButton);
      group.add(tiffButton);
 
      toolBar.add(gifButton);
      toolBar.add(jpgButton);
      toolBar.add(tiffButton);
 
      getContentPane().setLayout(new BorderLayout());
      getContentPane().add(BorderLayout.NORTH, toolBar);
 
      addWindowListener(new WindowAdapter() {
         public void windowClosing(WindowEvent we) {
            System.exit(0);
         }
      });
   }
      
   public static void main(String []args) {
      Main main = new Main();
      main.setSize(300, 300);
      main.setVisible(true);
   }
}