Cursor setting when having several JPanel in a JLayeredPane

Hello,

I have placed two JPanel in different layers of a JLayeredPane.

The lower panel sets cursors on several objects. When only this panel is in the JLayeredPane the cursors are shown ok.

But when I placed a second JPanel (transparent of course) above the 1st one the cursors are not set. Everything seem to be the same in the lower panel but for the cursors.

Any clue why this is so?

Thanks.

[431 byte] By [Eduardo_Cobiana] at [2007-10-2 17:40:53]
# 1
> But when I placed a second JPanel (transparent of course) Well, I would guess that even though the panel is transparent it is receiving the events not the panel below so the cursor will never change. Sounds like you need to add your cursor change code to the upper panel as
camickra at 2007-7-13 18:58:16 > top of Java-index,Desktop,Core GUI APIs...
# 2

Hello,

I have thought of that possibility but it is really to complicate things a lot. I would have to know in which object of the lower layer the mouse is and then change the cursor.

There must be a way to do it the simple way.

I am running across lot of "weird" things in java like when changing an attribute in a JTexPane and it only works for the next two characters you type then the default attribute is magically reset back to default.

Also so the JTextPane is not editable you still can select text with the mouse which doesn't make any sense. Oh well.

Eduardo_Cobiana at 2007-7-13 18:58:16 > top of Java-index,Desktop,Core GUI APIs...
# 3

> I am running across lot of "weird" things in java

Sounds like your code is wierd.

> like when changing an attribute in a JTexPane and it only works for

> the next two characters you type then the default attribute is magically reset back to default.

Never had a problem. Read the JTextPane API. You will find a link to the Swing tutorial on 'Using Text Components" which has a working example of setting attributes.

Don't blame Java for your lack of understanding!

> Also so the JTextPane is not editable you still can select text with the mouse which doesn't make any sense

Sure it does. I can select and copy any text from this web page even though it isn't editable.

"editable" means you can't type into the text component. It doesn't say "uncopyable".

So don't editorialize your comments. Just state what you are trying to accomplish.

camickra at 2007-7-13 18:58:16 > top of Java-index,Desktop,Core GUI APIs...