JFrame - mouse click using JComponent and MouseListener

前端 未结 1 1876
感动是毒
感动是毒 2021-01-26 23:59

Having 2 classes -

public class MainClass {



  public static void main(String[] args)  {
    JFrame frame = new JFrame();
    ....
    Component mouseClick =         


        
相关标签:
1条回答
  • 2021-01-27 00:24

    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:

    frame.addMouseListener((MouseListener) mouseClick);
    
    0 讨论(0)
提交回复
热议问题