🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.jbuilder.java.swing
4 messages
4 total messages Started by Ted Byers Wed, 24 Mar 2004 05:40
How does one ensure that transparent JLabel is displayed over top another JLabel
#1089
Author: Ted Byers
Date: Wed, 24 Mar 2004 05:40
19 lines
1941 bytes
I am having trouble with how JLabels are displayed.  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.  But the statement
"jLabel2.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));" doesn't
work, regardless of whether I put it in jbInit (where it belongs) or in the
mouseover event handler.

Any ideas regarding what is awry?

Thanks,

Ted
Re: How does one ensure that transparent JLabel is displayed over top another JLabel
#1097
Author: John McGrath [TeamB]
Date: Thu, 25 Mar 2004 22:38
36 lines
2368 bytes
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?

> 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?

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?

-- 
Regards,

John McGrath [TeamB]

---------------------------------------------------
Before sending me e-mail, please read:
    http://www.JPMcGrath.net/newsgroups/e-mail.html
Re: How does one ensure that transparent JLabel is displayed over top another JLabel
#1098
Author: 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
Re: How does one ensure that transparent JLabel is displayed over top another JLabel
#1100
Author: John McGrath [TeamB]
Date: Thu, 25 Mar 2004 23:18
42 lines
2589 bytes
On 3/25/2004 at 6:05:21 PM, Ted Byers wrote:

> > 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.

OK, but that is not display.  I take it they are being displayed
correctly?

> 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.  

Then you have to make sure that the "hotspot" label is in front.  You
should be able to do that with a right-click / "bring to front" in the
UI Designer.

> 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 really 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 

Mouse events go the the top-most component that has a mouse listener,
so they get through to the hotspot label even if it is underneath.  I
do not think that is the case for cursors.

> the area covered by the invisible label.

You might find it easier to work with at first by setting a border on
the invisible JLabel, which will make it easier to see.  You can remove
the border when once you get things working.

-- 
Regards,

John McGrath [TeamB]

---------------------------------------------------
Before sending me e-mail, please read:
    http://www.JPMcGrath.net/newsgroups/e-mail.html
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads