Check out example codes for "java swing menu click event". It will help you in understanding the concepts better.

Code Example 1

JMenuItem menuItem = new JMenuItem(new AbstractAction("My Menu Item") {
    public void actionPerformed(ActionEvent e) {
        // Button pressed logic goes here
    }
});

Learn ReactJs, React Native from akashmittal.com