You should be able to understand it. This is an example of a transparent panel. You can use this method to create other transparent components. Send me a letter if you have any questions. 8 -)
I hope to share my experience with you.
Package com. borland. samples. welcome;
Import java. awt .*;
Public class MyPanel extends Panel {
Private Image bi; // offscreen image
Private Graphics big; // Graphics for the offscreen image
Public void update (Graphics g ){
Paint (g );
}
Public void paint (Graphics g ){
If (bi = null) {// you can't do this from the constructor
Bi = createImage (getSize (). width, getSize (). height );
Big = bi. getGraphics ();
}
Rectangle area = g. getClipBounds (); // this is the area that needs to be (re) painted (no need to repaint everything)
Big. setClip (area );
Big. clearRect (area. x, area. y, area. width, area. height ); // fills the area with the background color // the next statement will call the paint methods for the other panels/components you have added to this panel // and draw them to the offscreen image
Super. paint (big); // now draw the offscreen image to the panel
G. drawImage (bi, area. x, area. y, area. x + area. width, area. y + area. height, area. x, area. y, area. x + area. width, area. y + area. height, this );
}
}