class TreeViewMenu extends MenuBase
{
    public static final String VIEW_PAGES = "Show pages";
    public static final String VIEW_STRUCTURE = "Internal structure";
    public static final String VIEW_CROSS_REF_TABLE = "Cross reference table";

    private static final List<String> validTreeModes = Arrays.asList(VIEW_PAGES, VIEW_STRUCTURE,
            VIEW_CROSS_REF_TABLE);

    private static TreeViewMenu instance;
    private JRadioButtonMenuItem pagesItem;
    private JRadioButtonMenuItem structureItem;
    private JRadioButtonMenuItem crtItem;

    /**
     * Constructor.
     */
    private TreeViewMenu()
    {
        setMenu(createTreeViewMenu());
    }

    /**
     * Provides the TreeViewMenu instance.
     * 
     * @return TreeViewMenu instance.
     */
    public static TreeViewMenu getInstance()
    {
        if (instance == null)
        {
            instance = new TreeViewMenu();
        }
        return instance;
    }

    /**
     * Set the tree view selection.
     * 
     * @param selection String instance.
     */
    public void setTreeViewSelection(String selection)
    {
        switch (selection)
        {
        case VIEW_PAGES:
            pagesItem.setSelected(true);
            break;
        case VIEW_STRUCTURE:
            structureItem.setSelected(true);
            break;
        case VIEW_CROSS_REF_TABLE:
            crtItem.setSelected(true);
            break;
        default:
            throw new IllegalArgumentException("Invalid tree view selection: " + selection);
        }
    }

    /**
     * Provide the current tree view selection.
     * 
     * @return the selection String instance
     */
    public String getTreeViewSelection()
    {
        if (pagesItem.isSelected())
        {
            return VIEW_PAGES;
        }
        if (structureItem.isSelected())
        {
            return VIEW_STRUCTURE;
        }
        if (crtItem.isSelected())
        {
            return VIEW_CROSS_REF_TABLE;
        }
        return null;
    }

    /**
     * Checks if the given viewMode value is a valid one.
     * 
     * @param viewMode the view mode to be checked
     * @return true if the given value is a valid view mode, otherwise false
     */
    public static boolean isValidViewMode(String viewMode)
    {
        return validTreeModes.contains(viewMode);
    }

    private JMenu createTreeViewMenu()
    {<FILL_FUNCTION_BODY>}
}

        JMenu menu = new JMenu();
        menu.setText("Tree view");

        pagesItem = new JRadioButtonMenuItem();
        structureItem = new JRadioButtonMenuItem();
        crtItem = new JRadioButtonMenuItem();
        pagesItem.setSelected(true);

        ButtonGroup bg = new ButtonGroup();
        bg.add(pagesItem);
        bg.add(structureItem);
        bg.add(crtItem);

        pagesItem.setText(VIEW_PAGES);
        structureItem.setText(VIEW_STRUCTURE);
        crtItem.setText(VIEW_CROSS_REF_TABLE);

        menu.add(pagesItem);
        menu.add(structureItem);
        menu.add(crtItem);

        return menu;
    
<methods>public void addMenuListeners(java.awt.event.ActionListener) ,public javax.swing.JMenu getMenu() ,public void setEnableMenu(boolean) <variables>private javax.swing.JMenu menu