Check out example codes for "actionListener java". It will help you in understanding the concepts better.

Code Example 1

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/*in main*/
button.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent e) {
			System.out.println('x');
  }
});

Code Example 2

JButton Button = new JButton();
Button.setSize(300,300);
Button.addActionListener(new ActionListener() {
	public void actionPerformed(ActionEvent e) 
    System.out.println(BlockNumber)
  	}
});

Code Example 3

button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent actionEvent) 
            {
              
            }
        });

Learn ReactJs, React Native from akashmittal.com