|
Replies:
5
-
Last Post:
Jul 24, 2008 11:02 PM
by: lndeveloper
|
|
|
|
|
|
|
Pass events through the layers of a JLayeredPane
Posted:
Jul 22, 2008 3:24 AM
|
|
|
I am using java/swing. Inside a JLayeredPane I have put various objects at various layers. As a result mouseclick events are caught only by the actionlisteners of the top level objects. I want to further "forward" these events to the underlying layer objects.
So the top-level objects handle the event first, and then "somehow" the event is forwarded to the next underlying level. If there is an object located at the underlying level at this position (and there is an actionlistener settled) the event is caught by this actionlistener and so on. I want all the process to be totally "transparent" for the objects at each layer, meaning that the object at each layer will not be able to distinguish if the event is fired from the user or being forwarded by an upper level.
Any ideas?
|
|
|
|
|
|
|
Re: Pass events through the layers of a JLayeredPane
Posted:
Jul 22, 2008 5:52 AM
in response to: lndeveloper
|
 |
Helpful |
|
|
Hello lndeveloper
It is practically impossible to manually "forward" events which are caught by another component,
you'll have all kinds of problems if you continue this way
see A well-behaved GlassPane for more details
The JXLayer component may also be interesting for you
Thanks
alexp
|
|
|
|
|
|
|
|
Re: Pass events through the layers of a JLayeredPane
Posted:
Jul 22, 2008 10:28 PM
in response to: alexfromsun
|
|
|
Although I didn't explore all the features of JXLayer, I understand that the main issue is to draw on top of other components, while they are still active. That's really cool, but I think it is not the solution to my problem.
It would be more helpful if I could make the overlay drawing catch some events, while the underlying componets catch some other events. Is it possible?
|
|
|
|
|
|
|
|
Re: Pass events through the layers of a JLayeredPane
Posted:
Jul 23, 2008 4:48 AM
in response to: lndeveloper
|
|
|
Hello lndeveloper
It is possible with JXLayer - you make a custom LayerUI, override e.g. processMouseEvents() method and catch all mouse events there, for mouseEvents which you don't want to pass to the underlying components you call event.consume(), that's it
Thanks alexp
|
|
|
|
|
|
|
|
Re: Pass events through the layers of a JLayeredPane
Posted:
Jul 24, 2008 11:02 PM
in response to: alexfromsun
|
|
|
Thank you alexfromsun!
|
|
|
|
|