Results 1 to 5 of 5
- 04-23-2011, 02:52 PM #1
Member
- Join Date
- Feb 2011
- Posts
- 53
- Rep Power
- 0
using the mousedrag in a conditional loop
Hey, iv been struggling trying to find a way to use the MOUSE_DRAGGED event in an if condition. I dont want to access it in the function that has to be declared below :
Id like to access the mouse dragged event from an if condition like below :Java Code:public void mouseDragged(MouseEvent e) { }
So if anyone could show me a better way of using the drag event in an if condition id be very grateful :)Java Code:if (e.MOUSE_DRAGGED == 506) { //do something, im using 506 as its the only drag event value i have found }
-
Can you clarify your question greatly? What overall problem are you trying to solve and why won't a mouse listener and its mouseDragged method help you?
- 04-23-2011, 03:42 PM #3
Member
- Join Date
- Feb 2011
- Posts
- 53
- Rep Power
- 0
Part of the problem is that the mouse listener doesent seem to recognise there has been a mouse dragged event when i drag the mouse using the method below :
Iv added the listener, as shown below:Java Code:public void mouseDragged(MouseEvent e) { System.out.println("mouse dragged"); }
and this method works for the mouseclicked function but not mouse dragged, if i drag the mouse nothing happens at all. So im trying to achieve the same result using an if condition. Any advice would be great.Java Code:PaintCanvas() { //constructor addMouseListener(this); }
-
That's because you have to add it as a MouseMotionListener to capture mouseDragged, not a MouseListener. Have you gone through the tutorials and API? It's all explained there.
- 04-23-2011, 03:55 PM #5
Member
- Join Date
- Feb 2011
- Posts
- 53
- Rep Power
- 0
Similar Threads
-
conditional statement
By blindfolded916 in forum New To JavaReplies: 12Last Post: 07-11-2010, 09:09 AM -
Moving whole content of JScrollPane by mousedrag
By Taiko in forum AWT / SwingReplies: 4Last Post: 01-16-2010, 08:44 PM -
JSP Help - Conditional Meta Tags
By jakavan in forum New To JavaReplies: 0Last Post: 12-08-2008, 06:34 PM -
how to do conditional looping?
By chennee72 in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 09-09-2008, 12:38 PM -
JFrame Conditional Close
By hemanthjava in forum AWT / SwingReplies: 10Last Post: 06-29-2008, 07:49 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks