0

Is there an actionMap-like thing for mouse clicks?

Thank you in advance, ive tried google, but did not find anything :/

2
Contributors
5
Replies
6
Views
5 Years
Discussion Span
Last Post by Erlendftw
Featured Replies
  • If it crashed then you were doing something wrong - the whole of Swing relies on mouse listening, and its really solid code. Try again? Read More

0

Not that I know of - I think you just have to get down & dirty with MouseListener, MouseWheelListener, and MouseMotionListener

0

I think i get the JPanel crash with MouseListener too, tried it a few days, ago.. and did stuff correct i think.

1

If it crashed then you were doing something wrong - the whole of Swing relies on mouse listening, and its really solid code. Try again?

0

Tried again now, did

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

public class test extends JPanel implements MouseListener


and all of the method: mouseClicked, mouseEntered, mouseExited, mousePressed, mouseReleased

I think the trouble is caused by focusing, i had trouble with KeyListener earlier on, and had to use keybindings. You sure its nothing similar for mouse?

0

Nevermind, i forgot to add the addMouseListener(this); line. Sorry for my stupidity, thought i had it all.

Thanks anyway! :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.