Meaningless Drivel is fun!*
The moose likes Swing / AWT / SWT and the fly likes How to propogate an event? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to propogate an event?" Watch "How to propogate an event?" New topic
Author

How to propogate an event?

Jane Griscti
Ranch Hand

Joined: Aug 30, 2000
Posts: 3141
Hi ... can anyone point me to an example or explain how an event can be passed up to it's container.
I'm using a JLayeredPane to hold some JPanels. The JPanels in turn contain a JEditPane and may contain other components.
The user needs to be able to click on any one panel and have it move to the front. Problem is, the JEditPane fills the panel and ends up receiving the mouseClick; I need it to be passed on to the InfoLayer which has a listener that manipulates the panels.
Thanks
[This message has been edited by Jane Griscti (edited December 05, 2001).]


Jane Griscti
SCJP, Co-author Mike Meyers' Java 2 Certification Passport
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Jane,
I am not really sure if this will work for you, but I can tell you about it anyway. The following command will place an event into the system queue so that it can be sent to registered listeners:
Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent( ae );
where ae is any AWTEvent. In your case you might be able to create a new AWTEvent using information from the one that you have received and just changing the source field to get it to work right.
Regards,
Manfred.
Jane Griscti
Ranch Hand

Joined: Aug 30, 2000
Posts: 3141
Thanks Manfred. I'll try it out.
Jane Griscti
Ranch Hand

Joined: Aug 30, 2000
Posts: 3141
This turned out to be fairly simple. Just posting the code in case anyone else needs it down the line
<pre>
public void mouseClicked(MouseEvent e){

InfoPanel ancestor = (InfoPanel) SwingUtilities.getAncestorOfClass(
InfoPanel.class,
(Component) e.getSource() );

MouseEvent me = new MouseEvent( ancestor,
e.getID(),
e.getWhen(),
e.getModifiers(),
e.getX(),
e.getY(),
e.getClickCount(),
e.isPopupTrigger() );
ancestor.dispatchEvent( me );
}
</pre>
------------------
Jane Griscti
Sun Certified Programmer for the Java� 2 Platform
Co-author Mike Meyers' Java 2 Certification Passport
[This message has been edited by Jane Griscti (edited December 05, 2001).]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to propogate an event?
 
Similar Threads
Passed!
Swing
Passed 149/155
I need a little guidance
Swing