• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to detect click on panel

 
Karen Nelson
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody,
This is a hopelessly newbie question. I need to detect mouse clicks on a panel, and I'm not sure which Listener interface to use. I tried to use MouseListener but I got the 'symbol not recognized' message when I tried to compile:



I think I have the MouseListener right:


As a more general question, is there a list somewhere of the common events and how to code them?

Thank you! Karen.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Change

silPanel.addActionListener(new MyMouseListener());

to

silPanel.addMouseListener(new MyMouseListener());
 
Stuart Gray
Ranch Hand
Posts: 410
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As a more general question, is there a list somewhere of the common events and how to code them?

There is indeed: http://java.sun.com/docs/books/tutorial/uiswing/events/index.html
 
Karen Nelson
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As always, Thank you!!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!