Difficulties with component events

D

DeMarcus

Hi,

How can I detect mouseclicks outside my component
without having to know about all other components
existing?

Thanks.
Daniel
 
D

DeMarcus

DeMarcus said:
Hi,

How can I detect mouseclicks outside my component
without having to know about all other components
existing?

Thanks.
Daniel

I found some interesting way of detecting the mouse
clicks with the following code.

getRootPane().getGlassPane().setVisible( true );
getRootPane().getGlassPane().addMouseListener( this );

But now that glassPane steals every mouse event. I just
wanna snoop the events. Does anyone have an idea how
I forward the events to where they belong?
 
J

John C. Bollinger

DeMarcus said:
I found some interesting way of detecting the mouse
clicks with the following code.

getRootPane().getGlassPane().setVisible( true );
getRootPane().getGlassPane().addMouseListener( this );

But now that glassPane steals every mouse event. I just
wanna snoop the events. Does anyone have an idea how
I forward the events to where they belong?

You cannot easily "forward" events the way I think you mean. It is much
more straightforward to allow the correct component to generate the
correct event in the first place. You might instead consider
JFrame.getTookit().addAWTEventListener(), which I think will let you do
what you want with much less hassle.


John Bollinger
(e-mail address removed)
 
D

DeMarcus

John said:
You cannot easily "forward" events the way I think you mean. It is much
more straightforward to allow the correct component to generate the
correct event in the first place. You might instead consider
JFrame.getTookit().addAWTEventListener(), which I think will let you do
what you want with much less hassle.


John Bollinger
(e-mail address removed)

Great Thanks!
One could say that was _exactly_ what I was looking for.
Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top