/*
 *  ==============================================================
 *  DemoCheckBoxMenuItem.java : Create checkbox menu iterms.
 * 
 *  Adapted from : Pantham S., Pure JFC Swing, 1999.
 *  Modified by : Mark Austin                          March, 2001
 *  ==============================================================
 */
  
import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
import java.awt.event.*;
 
public class DemoCheckBoxMenuItem extends JApplet {
 
    public void init() {

        // 1. Get the handle on the applet's content pane.

        Container container = this.getContentPane();
        
        // 2. Create a menu bar and add it to the applet.

        JMenuBar menuBar = new JMenuBar();
        menuBar.setBorder(new BevelBorder(BevelBorder.RAISED));

        //menuBar.setBorderPainted(true);        

        container.add(menuBar, BorderLayout.NORTH);          
         
        // 3. Create and add the File menu and its menu items.

        JMenu fileMenu = new JMenu("File", true);
        menuBar.add(fileMenu);
              
        // 4. Create the Edit menu and its menu items
        // and add them to the menu bar.

        JMenu editMenu = new JMenu("Edit");
        menuBar.add(editMenu);
        
        // 5. Create the Options menu, submenus, and their items.

        JMenu optionsMenu = new JMenu("Options");
        menuBar.add(optionsMenu);        
                         
        // 6. Create and add the Fonts options menu to the
        // Options menu.

        JMenu fontsOptionsMenu = new JMenu("Fonts");
        optionsMenu.add(fontsOptionsMenu);

        // 7. Create radio button menu items and add them
        // to the Fonts option menu.

        JRadioButtonMenuItem rbItem;
        ButtonGroup group = new ButtonGroup();
        String[] rbLabels = {"Dialog", "Monospaced", "SansSerif"};
        for (int i=0; i<rbLabels.length; i++) {
            rbItem = new JRadioButtonMenuItem(rbLabels[i]);
            fontsOptionsMenu.add(rbItem);
            group.add(rbItem);
        }

        // 8. Create and add the Others options menu to the
        // Options menu.

        JMenu advancedOptionsMenu = new JMenu("Others");
        optionsMenu.add(advancedOptionsMenu);

        // 9. Create and add the check box menu items to the
        // Others options menu.

        JCheckBoxMenuItem  cbItem;
        String[] cbLabels =  {"Load Images", "Enable Java",
                              "Enable JavaScript"};
        for (int i=0; i<cbLabels.length; i++) {
            cbItem = new JCheckBoxMenuItem(cbLabels[i]);
            advancedOptionsMenu.add(cbItem);
        }
    }      
}
