JLabel transparent?

U

Uli Kunkel

I have the following situation:

JPanel
JLabel1
JLabel2

On Jlabel1 I set some picture (ImageIcon), and I want to have a JLabel2
over it and transparent.
In that way I could overlap the 2 pictures.

The problem is that JLabel2 is not transparent even with setOpaque to false.

I'd appreciate any suggestions.
 
U

Uli Kunkel

Uli said:
I have the following situation:

JPanel
JLabel1
JLabel2

On Jlabel1 I set some picture (ImageIcon), and I want to have a JLabel2
over it and transparent.
In that way I could overlap the 2 pictures.

The problem is that JLabel2 is not transparent even with setOpaque to
false.

I'd appreciate any suggestions.


After changing the layout to BoxLayout the JLabel2 is transparent.
I have another problem. On JLabel2 I use setIcon(imageFile) and set the
image of a label. That image is mostly made of transparent pixels.

The problem now is that this image has the "control color" where the
transparent pixels should be.
 
U

Uli Kunkel

Uli said:
After changing the layout to BoxLayout the JLabel2 is transparent.
I have another problem. On JLabel2 I use setIcon(imageFile) and set the
image of a label. That image is mostly made of transparent pixels.

The problem now is that this image has the "control color" where the
transparent pixels should be.


1.So can I have Jpanel and 2 labels overlapping?
If so what layout should I use?

2.Or maybe I have to use LayeredPane?
 
J

John B. Matthews

I have the following situation:

JPanel
JLabel1
JLabel2

On Jlabel1 I set some picture (ImageIcon), and I want to have a
JLabel2 over it and transparent. In that way I could overlap the 2
pictures.

The problem is that JLabel2 is not transparent even with setOpaque
to false.

I'd appreciate any suggestions.

After changing the layout to BoxLayout the JLabel2 is transparent. I
have another problem. On JLabel2 I use setIcon(imageFile) and set the
image of a label. That image is mostly made of transparent pixels.

The problem now is that this image has the "control color" where the
transparent pixels should be.[/QUOTE]

Here's an example of using transparency in a JLabel:

<http://sites.google.com/site/drjohnbmatthews/composite>
 
U

Uli Kunkel

John said:
After changing the layout to BoxLayout the JLabel2 is transparent. I
have another problem. On JLabel2 I use setIcon(imageFile) and set the
image of a label. That image is mostly made of transparent pixels.

The problem now is that this image has the "control color" where the
transparent pixels should be.

Here's an example of using transparency in a JLabel:

<http://sites.google.com/site/drjohnbmatthews/composite>
[/QUOTE]

Thank you for the reply.
In the meantime I tried to use JLayeredPane (no layout manager) and got
it to work as I wished.
The ordinary JPanel was confusing to use with multiple layers..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top