Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

MouseAdapter Problem  RSS feed

 
S Connor
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I'm working on some code that needs to respond to mouse inputs. I'm trying to implement the MouseListener. The aim of the project is to allow the user to draw shapes in a window. At present I don't get any response to attempts to override the mouseClicked() method, though bizarrely I can get a response to mouseDragged().

I set up a new project to isolate the MouseAdapter code and the problem persists:

Any help gratefully appreciated
 
Rob Camick
Ranch Hand
Posts: 2754
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't get any response to attempts to override the mouseClicked() method, though bizarrely I can get a response to mouseDragged().


That is because "mouseClicked" is generated by a MouseListener and "mouseDragged" is generated by a MouseMotionListener.

You did not add the MouseListener to you component.
 
S Connor
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you, problem solved
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!