I'm having a problem painting a background on a JPanel. I have the following written:
I'm working in an Applet and I'm calling getImage() to get the image. I get the message saying "Painting..." but the JPanel is still all gray. Does anyone have any ideas why this wouldn't work? Thanks a lot.Code:public class ImageBackgroundPainter implements IBackgroundPainter { private Image _image; public ImageBackgroundPainter(Image img) { _image = img; } public void init(JComponent comp) { comp.setSize(_image.getWidth(comp), _image.getHeight(comp)); } public void paint(JComponent comp, Graphics g) { System.out.println("Painting..."+_image); g.drawImage(_image, 0, 0, comp); } } public class HotSpotPanel extends JPanel { private IBackgroundPainter _background; public HotSpotPanel(IBackgroundPainter background) { super(true); _background = background; initComponents(); } public void paint(Graphics g) { super.paint(g); _background.paint(this,g); paintComponents(g); } protected void initComponents() { } }


Reply With Quote


Bookmarks