🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

redispatching MouseEvents from GlassPane

#10564
From: Eelco Hillenius
Date: Thu, 09 Sep 1999 00:00
61 lines
2364 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



--
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: <936891735.399497@tbird.introweb.nl>
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,3666932cdc70eac7,start
X-Google-Attributes: gid111d45,public
From: "Eelco Hillenius" <illy@cybercomm.nl>
Subject: redispatching MouseEvents from GlassPane
Date: 1999/09/09
Message-ID: <936891735.399497@tbird.introweb.nl>
X-Deja-AN: 522990101
Cache-Post-Path: tbird.introweb.nl!unknown@ip51-115.introweb.nl
Organization: IntroWeb Newsserver
X-MSMail-Priority: Normal
X-Priority: 3
X-Cache: nntpcache 2.3.3 (see http://www.nntpcache.org/)
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211
Newsgroups: borland.public.jbuilder.java.swing