Let's imagine I have a program like the source below:
public class Main extends JFrame implements MouseListener {
public Main() {
this.setVisible(true);
this.addMouseListener(this);
}
public static void main(String[] args) {
new Main();
}
@Override
public void mousePressed(MouseEvent e) {
System.out.println("clicked!");
}
}
in order to run this program and have out output (in this case when user clicked on the jframe shows "clicked") the user has to specifically click the jframe but I want to say if user clicked anywhere show me this output but I don't know how to make the program do that