Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting multiple mousePressed events with one click

Status
Not open for further replies.

BPMan

Programmer
Jun 25, 2002
163
US
I have the following code:
addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{

System.out.println("MousePressed");
}});

and when i first open my program and i click on the Canvas i get one mousePressed event...
but if I resize or click a button and then click back on the canvas I will get multiple moused pressed events.
Why is this happening and how can i fix it?????
Thanks
 
Why not just use the mouseClicked() event instead if you require "click" events ?
 
i need mouse pressed and mousereleased or whatever it is...my problem is it is giving multible mousepressed, i am not sure if it is giving multiple mouse clicks or not but it should give the same amount....
anyways i have to used mousepressed...
any thoughts on why i might be getting multiple events on one click?
 
Because when you are resizing a window, you are "pressing the mouse" constantly. Its not a click, its a constant press.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top