This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes get constant parameter from mouseEvent Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "get constant parameter from mouseEvent" Watch "get constant parameter from mouseEvent" New topic
Author

get constant parameter from mouseEvent

alona ariel
Ranch Hand

Joined: Sep 09, 2008
Posts: 36
I will to ask my question better

I try this code to get x,y paremeters, but I want constant parameter and not a parameters that change all the time
How can I do it

public void init()
{


addMouseMotionListener(this);
}

{
public void mouseMoved(MouseEvent me)

xpos = me.getX();
ypos = me.getY();

}
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14672
    
  11

Unless your mouse is scotched to your desk (in which case the mouseMoved event would not be fired), its coordinates will obviously change.

What are you trying to achieve exactly ?


[My Blog]
All roads lead to JavaRanch
alona ariel
Ranch Hand

Joined: Sep 09, 2008
Posts: 36
My programm is to dragged a vector and and calculate the vector length so I need constant parameter
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32673
    
    4
What about a MouseListener?
alona ariel
Ranch Hand

Joined: Sep 09, 2008
Posts: 36
okey it is worked better now.
but what about if I want two or more vectors so I need to maintain the former parameters?
Kevin Workman
Ranch Hand

Joined: Sep 28, 2010
Posts: 151
alona ariel wrote:okey it is worked better now.
but what about if I want two or more vectors so I need to maintain the former parameters?


Use a List? I'd recommend you go through the basic tutorials again.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: get constant parameter from mouseEvent
 
Similar Threads
jtable right mouse click
Creating mouse rollover for for custom drawn JButton
How to add a MouseListener to a ScrollPane?
Drawing Problem
compile error