import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.lang.reflect.InvocationTargetException;

import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

public class App {
    public static void main(String[] args) {
        String lookAndFeel = UIManager.getSystemLookAndFeelClassName();
        try {
            UIManager.setLookAndFeel(lookAndFeel);
            } catch (ClassNotFoundException e) {
            e.printStackTrace();
            } catch (InstantiationException e) {
            e.printStackTrace();
            } catch (IllegalAccessException e) {
            e.printStackTrace();
            } catch (UnsupportedLookAndFeelException e) {
            e.printStackTrace();
        }

        System.setProperty("apple.laf.useScreenMenuBar", "true");

        try {
            SwingUtilities.invokeAndWait(new Runnable() {
                @Override
                public void run() {
                    JFrame frame = new JFrame("App");
                    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                    frame.setSize(400, 300);
                    frame.setLocationRelativeTo(null);

                    JMenuItem newFolder = new JMenuItem("My Menu Item");
                    newFolder.addActionListener(new FolderHandler());

                    JMenu fileMenu = new JMenu("File");
                    fileMenu.add(newFolder);

                    JMenuBar menuBar = new JMenuBar();
                    menuBar.add(fileMenu);
                    frame.setJMenuBar(menuBar);

                    frame.setVisible(true);
                }
            });
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        } catch (InterruptedException e) {
             e.printStackTrace();
        }
    }

    private static class FolderHandler implements ActionListener {
        @Override
        public void actionPerformed(ActionEvent e) {
            System.out.println("My Menu Item is executed");
        }
    }
}