Paiting on a panel

Hi all,
Blah^3 screenies of his editor gave me ideas, lots em having to rely on painting to a panel.

The reason I would like to paint onto a panel is because id like to combine buttons/tabs…etc on other panels to transform that paintablePanel.

Can anybody direct me, or even better, provide me with some code to see how its done?

thx

The simplest way is to override the paint( Graphics ) method and do whatever painting you want to do there.
The Graphics object that gets passed in is what you will need for all of your painting needs.

It’s usually better to override paintComponent(…). Then you can still set the border in the usual way and it will be painted.

Cheers

cool, so would making a ImagePanel ( i couldn’t think of a better name) that I would pass an image down to and it would render the image onto itself?


public void setImage(Image img) {
   this.img = img;
}

public void paintComponent(Graphics g) {
  super.paintComponent(g);
  g.drawImage(img, 0, 0, null);
}

Is that the kind of thing you would do?