• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with MouseEvents  RSS feed

 
kumar mars
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai
I have a problrm with mouse events.
i have a JPanel. I added MouseInputAdapter and a MouseMotionListener to this panel.
The problem is whenever i click the mouse at two different points (considerably distanced) consecutively, instead of two MouseClicked events a MouseDragged event is getting generated.
I am using J2SDK1.3. Some boby pl tell me reason and remedy for this.
Anticipating an early reply
With Regards
Maruti
 
Peter Reinhardt
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
have you used panel.addMouseListener(myListener) or addMouseMotionListener(myListener)?
with and MouseInputAdapter you can do both.
Peter.
 
kumar mars
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have Done the Both
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How close together ( in time, not space ) are you making the clicks? If you click, start dragging to make the second click, release, click again; the first click is seen as the start of the drag action.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!