package com.example.components;

import com.example.FileListContainer;

import javax.swing.*;

/**
 * @author innokenty
 */
public class FileBrowserMenuBar extends JMenuBar {

    private final FileListContainer listContainer;

    public FileBrowserMenuBar(FileListContainer container) {
        listContainer = container;
        super.add(buildFileMenu());
        super.add(buildViewMenu());
    }

    private JMenu buildFileMenu() {
        JMenu file = new JMenu("File");
        file.setMnemonic('f');
        return file;
    }

    private JMenu buildViewMenu() {
        JMenu view = new JMenu("View");
        view.setMnemonic('v');
        view.add(buildShowHiddenFilesItem());
        return view;
    }

    private JMenuItem buildShowHiddenFilesItem() {
        final JCheckBoxMenuItem item = new JCheckBoxMenuItem("Show hidden files");
        item.setMnemonic('h');
        new ShowHiddenFilesButtonDecorator(listContainer).decorate(item);
        return item;
    }
}

@@ -86,16 +86,89 @@
 swing.*;
+%0Aimport java.awt.event.ActionEvent;%0Aimport java.awt.event.ActionListener;
 %0A%0A/**%0A *
@@ -588,19 +588,392 @@
     
-return file
+file.add(buildQuitItem());%0A        return file;%0A    %7D%0A%0A    private JMenuItem buildQuitItem() %7B%0A        JMenuItem quit = new JMenuItem(%22Quit%22);%0A        quit.setMnemonic('q');%0A        quit.addActionListener(new ActionListener() %7B%0A            @Override%0A            public void actionPerformed(ActionEvent e) %7B%0A                System.exit(0);%0A            %7D%0A        %7D);%0A        return quit
 ;%0A  

add - "File > Quit" menu Item