🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #10505

REPOST: redispaching MouseEvents from GlassPane

#10505
From: Eelco Hillenius
Date: Thu, 16 Sep 1999 00:00
53 lines
2129 bytes
Hi,

In my Swing-app I'm using a GlassPane (JComponent) to draw on top of a frame
with various JPanels, JButtons etc. I would like to redispatch MouseEvents
(or maybe something else if it's more appropriate) to the components. I
can't get it done. I've tried (amongst others) this: (where e is de original
MouseEvent.

1). Component component =
SwingUtilities.getDeepestComponentAt(this.getContentPane(), point.x,
point.y);
MouseEvent me = new MouseEvent(component, e.getID(),
System.currentTimeMillis(), e.getModifiers(),
            point.x, point.y, e.getClickCount(), e.isPopupTrigger());
   e.consume();
   component.dispatchEvent(me);
 }

and this...

2). Component component =
SwingUtilities.getDeepestComponentAt(this.getContentPane(), point.x,
point.y);
     component.dispatchEvent(e);

and, ofcourse, this...

3). Component component =
SwingUtilities.getDeepestComponentAt(this.getContentPane(), point.x,
point.y);
      if(component.equals(someComponent)) {
          doSomething();
    }

Now, this last one (3) works fine, except for the fact that I have to catch
and analyse all posible actions on the components. The second one (2)
doesn't work at all; I got casting exceptions (source in e == the
glasspane). The first one (..<your guess>) keeps on delivering te event to
the target component (like an infinite loop), so that's also not quite what
I want.

Can anyone please help me on this? Thanks in advance,




--
Eelco Hillenius
Software Engineer

Blue Point Designware B.V.
tel +31 (0)74-250 60 00
email: eelco_hillenius@bluepoint.nl
Technical Details
Message-ID: <7rq821$smg13@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,d755ba80f32602b0,start
X-Google-Attributes: gid111d45,public
From: "Eelco Hillenius" <illy@cybercomm.nl>
Subject: REPOST: redispaching MouseEvents from GlassPane
Date: 1999/09/16
Message-ID: <7rq821$smg13@forums.borland.com>
X-Deja-AN: 525774184
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211
Organization: Another Netscape Collabra Server User
X-MSMail-Priority: Normal
Newsgroups: borland.public.jbuilder.java.swing