Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

JLabel, HTML, and Transparency

843807Sep 22 2010 — edited Sep 23 2010
When using a JLabel, I can get it to be transparent by doing:
label.setOpaque(true);
label.setBackground(new java.awt.Color(r, g, b, a));
This all works as expected unless the label itself contains html (for example, for a multi-line label:
label.setText("<html>Something on line 1<br>And on line 2</html>");
When encountering a label with html within it, the background for the section that contains text will remain solid. If the label itself is sized larger with resizing off, I can see the transparency is working correctly all around the area containing the text.

Does anyone have an idea on how to resolve this issue, or is some more information necessary?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 21 2010
Added on Sep 22 2010
8 comments
1,767 views