JApplet : Funktionalität zwieschen Container und paint()-Methode

PositivDenker

Mitglied
Guten Abend, Profis!
Mein JApplet kann nicht JLabel und drei Bilder gleichzeitig darstellen. Wenn ich paint() auskommentiere sehe ich meinen roter Container mit JLabel. Aber wenn ich die Methode wieder einschalte, sehe ich drei Bilder auf weissem Hintergrund.
Wie funktioniert graphische Hierarchie von SUN ?
Code:
import java.awt.*;
import java.applet.*;
import javax.swing.*;


 public class KombiApplet extends JApplet{

	private static final long serialVersionUID 		= 4413L;
	Image picture_1,picture_2,picture_3;
	JLabel jlab= new JLabel("Test");
	Container cont=null;

 public void init()
	{

	cont=getContentPane();
	cont.setLayout(null);
	cont.setBackground(Color.red);
	jlab.setBounds(4,270,100,16);
	cont.add(jlab);
	setSize(500,500);

	picture_1 =getImage(getCodeBase(), "1.jpg");
	picture_2 =getImage(getCodeBase(), "2.jpg");
	picture_3 =getImage(getCodeBase(), "3.jpg");

	prepareImage(picture_1, this);
	prepareImage(picture_2, this);
	prepareImage(picture_3, this);
	setContentPane(cont);
	repaint();
	}

  public void paint(Graphics g) 
    {
	g.drawImage(picture_1, 	4, 4, this);
	g.drawImage(picture_2, 188+	4, 4, this);
	g.drawImage(picture_3, 188*2+      4, 4, this);
	}
}
 
Zurück