Having 2 classes -
public class MainClass { public static void main(String[] args) { JFrame frame = new JFrame(); .... Component mouseClick =
In order to receive mouse clicks on your frame, you also need to add mouseClick to the frame's list of MouseListeners. Try adding this line after you create mouseClick:
mouseClick
MouseListeners
frame.addMouseListener((MouseListener) mouseClick);