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

Code Example 1

JButton b = new JButton("push me");
b.addActionListener(new ActionListener() {

    @Override
    public void actionPerformed(ActionEvent e) {
        //your actions
    }
});

Learn ReactJs, React Native from akashmittal.com