Background image under a list

Hello!I need to view a background image under a list.I've done this for a panel overriding the paint method but for a list it doesn't go.Can someone help me?Thanks
[200 byte] By [francy127a] at [2007-11-26 18:08:58]
# 1

It will work:

List list... // I don't know exactly what it is, but it should extand Container or Component

Container mainComponent = new Container(){

public void paint(Graphics g) {

//draw bg image

super.paint(g);

}

};

mainComponent.add(list);

I suppose your mistake is like one of discribed below:

1. in a method paint you invoke super.paint() before background image drawing

2. you add component which contains bgImage after adding list component

pashkina at 2007-7-9 5:40:47 > top of Java-index,Java Mobility Forums,Consumer and Commerce...
# 2

I believe that my code is right..

I extends List component and override the paint method.

First, I draw the image, then I call the super method.

Then, in a main method I add the list to a panel.

Where I'm wrong?

import java.awt.Graphics;

import java.awt.Image;

import java.awt.List;

import java.awt.Toolkit;

public class ListBg extends List{

private static final long serialVersionUID = 1L;

Image image;

public ListBg(){

super();

Toolkit toolkit = Toolkit.getDefaultToolkit();

image = toolkit.getImage("C:/Programmi/image.jpg");

}

public void print(Graphics g){

g.drawImage(image,0,0,this);

super.print(g);

}

}

francy127a at 2007-7-9 5:40:47 > top of Java-index,Java Mobility Forums,Consumer and Commerce...
# 3

> public void print(Graphics g){

> g.drawImage(image,0,0,this);

> super.print(g);

> }

> }

you should override method

public void paint(Graphics g){};

not print as you do.

In a case it was just mispaint share your whole class text for tests...

pashkina at 2007-7-9 5:40:47 > top of Java-index,Java Mobility Forums,Consumer and Commerce...
# 4
Yes..the paint method..I override the paint method (not print but I gave you the wrong code) but it doesn't go.Why?
francy127a at 2007-7-9 5:40:47 > top of Java-index,Java Mobility Forums,Consumer and Commerce...