السلام عليكم
اريد ان اضع خلفية للبنل حسب الكود التالي
import javax.swing.*;
import java.awt.*;
/** Demonstrate drawing an image. **/
public class ImageApplet extends JApplet
{
public void init () {
Container content_pane = getContentPane ();
// Grab the image.
Image img = getImage (getCodeBase (), "liftoff.jpg");
// Create an instanceof DrawingPanel
DrawingPanel drawing_panel = new DrawingPanel (img);
// Add the DrawingPanel to the content pane.
content_pane.add (drawing_panel);
} // init
} // class ImageApplet
class DrawingPanel extends JPanel
{
Image img;
DrawingPanel (Image img)
{ this.img = img; }
public void paintComponent (Graphics g) {
super.paintComponent (g);
// Use the image width & height to find the starting point
int imgX = getSize ().width/2 - img.getWidth (this);
int imgY = getSize ().height/2 - img.getHeight (this);
//Draw image centered in the middle of the panel
g.drawImage (img, imgX, imgY, this);
} // paintComponent
} // DrawingPanelعند تطبيق هاد الكود على برنامجي يعمل تمام ولكن المشكله ان الصورة وجميع الازرار والمكونات على البنل لا تظهر الا بعد الضغط بالماوس داخل الابلت وبعدها اي تحديث للابلت تبقة الصورة والمكونات موجودة
لماذا ؟؟
يصعب وضع الكود الاصلي لطوله


