🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: How to retrieve an object deep inside another object?

#777
From: Paul Furbacher [TeamB]
Date: Thu, 23 Dec 2004 04:47
64 lines
3027 bytes
Ramon F Herrera wrote:
> 
> This is a problem of some listeners being applied to the
> wrong object.
> 
> I am trying to write an application which places a
> JAI image on top of a JPanel and then performs some
> rubberbanding on the image.
> 
> I used the standard JBuilder wizard "New Application" and
> obviously I have added my own code as you can see below.
> 
> This is one of the critical pieces of code:
> 
>   ScrollingImagePanel sip = new ScrollingImagePanel(img, 950, 645);
>   frame.getContentPane().add(sip);
>   MainFrame frame = new MainFrame();
> 
> Later on, at the end of jbInit() I have these 2 lines:
> 
>    contentPane.addMouseListener(this);
>    contentPane.addMouseMotionListener(this);
> 
> Those 2 lines allow me to perform the rubberbanding on the
> JPanel (without the ScrollingImagePanel on top of it).
> So what I need is something like this (I think):

Rubber-banding might also be done by using a glass pane,
at least that's an approach I'd look into.  Have you done
the requisite Google on the topic?

Otherwise, you have two choices.

1. MainFrame can have a private ivar which is
set via

   setSIP(SIP sip) {
     this.sip = sip;
     sip.addMouseListener(this);
     sip.addMouseMotionListener(this);
   }

2. You can subclass the content pane, override the
    add() method.  Then set that custom content pane
    into your MainFrame via its "setContentPane()".
    Not too long ago, I think I read a JDJ article
    which did just this, but for what reason, I cannot
    remember.


-- 


Paul Furbacher (TeamB)

   Save time, search the archives:
        http://www.borland.com/newsgroups/ngsearch.html

   Is it in Joi Ellis's Faq-O-Matic?
        http://www.visi.com/~gyles19/fom-serve/cache/1.html

   Finally, please send responses to the newsgroup only.
   That means, do not send email directly to me.
   Thank you.
Technical Details
Message-ID: <41ca4dd6$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!news.wiretrip.org!border2.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <41ca2cc6$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 111d45,771a2b9d98407c09
X-Google-Attributes: gid111d45,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Wed, 22 Dec 2004 23:47:21 -0500
From: "Paul Furbacher [TeamB]" <pfurbacher@mac.com>
Organization: Reverse Alchemy, Inc.
User-Agent: Mozilla Thunderbird 0.8 (Macintosh/20040913)
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.jbuilder.java.swing
Subject: Re: How to retrieve an object deep inside another object?
References: <41ca2cc6$1@newsgroups.borland.com>
In-Reply-To: <41ca2cc6$1@newsgroups.borland.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 69.142.222.65
Message-ID: <41ca4dd6$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1103777238 69.142.222.65 (22 Dec 2004 20:47:18 -0800)
Lines: 64
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!news.wiretrip.org!border2.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail