Check out example codes for "java add listent to button". It will help you in understanding the concepts better.

Code Example 1

JButton button = new JButton("Do Something");
button.addActionListener( new ActionListener()
{
    @Override
    public void actionPerformed(ActionEvent e)
    {
        System.out.println("Do Something Clicked");
    }
});

Learn ReactJs, React Native from akashmittal.com