🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: How does one ensure that transparent JLabel is displayed over top another JLabel

#1098
From: Ted Byers
Date: Thu, 25 Mar 2004 23:05
56 lines
3514 bytes
Hi John,

Thanks.

"John McGrath [TeamB]" <ng-b@JPMcGrath.net> wrote in message
news:40635f50$1@newsgroups.borland.com...
> On 3/24/2004 at 12:40:53 AM, Ted Byers wrote:
>
> > I am having trouble with how JLabels are displayed.
>
> I think I understood the part about event handling, but what is wrong
> with the way that they display?
>
For the invisible one, the mouse cursor is supposed to change to a hand.

> > I have a background image loaded in one JLabel, and I created
> > a second, smaller one to use to make a hotspot on the first.
> > I have everything working, including the ability to add an
> > event handler to the second (and actually have it invoked),
> > except that the second JLabel is supposed to have a different
> > mouse pointer than the first (so I can have an obvious visual
> > cue for the availability of something to click for the area
> > covered by the second JLabel).  Alas, this part isn't working
> > in that the mouse pointer never changes.  I find this odd
> > since I DO get my mouse event handlers for the second JLable
> > invoked.
>
> This sounds like you are just placing two labels in a panel and you
> want to catch mouse events and set the mouse pointer for one of them.
> Is that correct?
>
Yes, this is correct.

> If so, it would help to know how you laid these two labels out in the
> parent container.  What layout manager and constraints did you use and
> in which order did you add them to the panel?  Do the two labels
> overlap?
>
I used the xylayout manager.  I put the label to hold the image first.  I
had to.  The second had to be placed relative to features in the image.
Yes, the labels overlap.  In fact the second is completely cntained within
the first.  They have to because I am using the second to create a hotspot
on the first.  It seemed like the natural way to do it.  I did something
similar, in a matter of a few minutes, using the VCL in Borland's C++
Builder.  But it is taking a wee bit longer using JBuilder.  :-(  I expect
it'd be taking a lot longer without JBuilder.

The odd thing is that the mouse click event is being handled exactly as I
expected and where, on the image, I expected.  So I realy don't understand
why the cursor is not being change back and forth between the hand and the
default pointer as the mouse enters and exists the area covered by the
invisible label.

Thanks again,

Ted
Technical Details
Message-ID: <406364a2$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!news.tele.dk!news.tele.dk!small.news.tele.dk!news-fra1.dfn.de!newsfeed.ision.net!ision!news.belwue.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <40611e78$1@newsgroups.borland.com> <40635f50$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,996c15d51938f6ca
X-Google-Attributes: gid111d45,public
X-Google-ArrivalTime: 2004-03-25 15:09:54 PST
From: "Ted Byers" <r.ted.byers@sympatico.ca>
Newsgroups: borland.public.jbuilder.java.swing
References: <40611e78$1@newsgroups.borland.com> <40635f50$1@newsgroups.borland.com>
Subject: Re: How does one ensure that transparent JLabel is displayed over top another JLabel
Date: Thu, 25 Mar 2004 18:05:21 -0500
Lines: 58
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: 65.95.240.180
Message-ID: <406364a2$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1080255650 65.95.240.180 (25 Mar 2004 15:00:50 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!news.tele.dk!news.tele.dk!small.news.tele.dk!news-fra1.dfn.de!newsfeed.ision.net!ision!news.belwue.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail