Gradient background

J

John M

Hello,

I want to make a label as a header to my tree panel. How is it possible to
make a gradient background color to this label ?

Thanks!
 
C

Chris Smith

K

Karsten Lentzsch

John said:
[...] How is it possible to make a gradient background
color to this label ?

I suggest to use a panel that paints a gradient background
and then add a label to it. You can then later add an optional
toolbar, icon, border, etc.

This is easy if you use a single l&f with a fixed set
of colors. Honoring a set of l&fs and multiple color themes
is a little bit harder.

I'm about to open source the Skeleton application that
will ship with a class SimpleInternalFrame that provides
an eclipse-like structuring panel. You can see it here:
http://www.jgoodies.com/freeware/looks/index.html

The three different screenshots demonstrate the problem
mentioned above. I've put some effort in honoring the
desktop colors to not alienate users with a custom gradient.

The Skeleton app and SimpleInternalFrame will be published
at JavaDesktop.org in the JGoodies subproject "demos".
This subproject is not yet visible to the general public.
I plan to release it to the general public later this year.

Hope this helps,
Karsten Lentzsch
 
C

Chris Smith

John said:
I want to make a label as a header to my tree panel. How is it possible to
make a gradient background color to this label ?

I don't see a canned way to set a label's background to a gradient. You
probably need to subclass JLabel and override its paintComponent method.
Gradients are relatively easy to do with java.awt.GradientPaint and
java.awt.Graphics2D.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 

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,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top