background image help

A

Ann

I have a tree and the background color is set as follows:

newContentPane.setOpaque(true); //content panes must be opaque
newContentPane.setBackground(new Color(1.0f, 0.6f, 0.6f));

I would like to use a gif file instead of a solid color
as a background image. How to? Or where to look please.
 
M

marcus

is this a JComponent? try JComponent.getGraphics() then
Graphics.drawImage() Of course you will need to have created a new
Image with the gif something like this (from the docs)
(java.awt.Toolkit.getImage())

Image src = getImage("doc:///demo/images/duke/T1.gif");
 

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,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top