/**
   * Creates the theme menu
   *
   * @return the theme menu
   */
  private JMenu createThemeMenu() {
    JMenu themeMenu = new JMenu("Theme");
    ButtonGroup buttonGroup = new ButtonGroup();

    // Create a menu item for all themes
    for (int i = 0; i < themes.length; i++) {
      JMenuItem themeItem = new JRadioButtonMenuItem(themes[i].getName());
      buttonGroup.add(themeItem);
      final int k = i;
      themeItem.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              // Apply the selected theme
              applyTheme(themes[k]);
            }
          });

      themeMenu.add(themeItem);

      // Set the first item (default theme) to be selected
      themeItem.setSelected(i == 0);
    }

    return themeMenu;
  }
 /**
  * Creates a menu item
  *
  * @param text menu text
  * @param listener action listener when menu item is selected
  * @return the menu item
  */
 private JMenuItem createMenuItem(String text, ActionListener listener) {
   JMenuItem item = new JMenuItem(text);
   item.addActionListener(listener);
   return item;
 }