File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT / JFace and the fly likes A gradient paint background for a JLabel Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT / JFace
Reply Bookmark "A gradient paint background for a JLabel" Watch "A gradient paint background for a JLabel" New topic
Author

A gradient paint background for a JLabel

Rupert Brown
Greenhorn

Joined: Jul 29, 2009
Posts: 16
I'm using a JTree that simply holds Strings. As I understand it, these Strings are written inside JLabels - its basically a tree of JLabels. I have successfully changed the background colour of my JLabels but - to make the JLabels match the look and feel of other GUI components I have created, I need to be able to put a gradient onto the background of the JLabel. Any ideas as to how I can do that?
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 7059

http://java.sun.com/products/jfc/tsc/articles/swing2d/index.html
Scroll down to the section on gradient painting


[Donate a pint, save a life!] [How to ask questions]
Rupert Brown
Greenhorn

Joined: Jul 29, 2009
Posts: 16
Thanks Maneesh - that looks like a great reference. I'll read it further, but it looks like a simple matter of creating the gradient paint, and then just using setPaint on the JLabel. Cheers.
 
 
subject: A gradient paint background for a JLabel
 
MyEclipse, The Clear Choice