I want to receive notifications about mouse events (in particular, about mouse input and exit) on my JFrame. But when I add a mouselistener to it, I get events at the borders of the frame, and not the whole frame with its contents.
Any ideas as to why?
EDIT: Or at least do you have an alternative? I want a “cloudy” way to catch mouse events on a JFrame. Maybe a mouselistener is not the answer.
You can get all the events and check if their source is a component in the JFrame.
See Toolkit.addAWTEventListener
, GUI, " ". . :
JFrame frame = new JFrame(); Component glassPane = frame.getGlassPane(); glassPane.addMouseListener(myListener);
, , . :
public void mouseMoved(MouseEvent e) { redispatchMouseEvent(e, false); }
(, JPanel) "" , JFrame.
, . .
AWTEventListener EventQueue. , WebStart .
AWTEventListener
EventQueue