In folgendem Codeausschnitt wird ein Bild gezeichnet. Dieses wird allerdings nicht dargestellt. Wenn ich die Kommentare in der draw-Funktion wegmache, werden die Kreise usw. angezeigt->die Funktion wird also aufgerufen. Ein weißes Zucken auf dem Bildschirm beweist außerdem, dass irgendwas zu zeichnen probiert wird. Warum wird das Bild nicht dargestellt?
Danke schonmal...
Campino
Code:
public class Figur {
private Rectangle2D.Double f;
private double x, y, w, h;
private Image img;
public Figur(double x, double y, double width, double height, Component comp){
this.x=x; this.y=y;
this.w=width; this.h=height;
f=new Rectangle2D.Double(x, y, w, h);
img=Toolkit.getDefaultToolkit().getImage("figur.gif");
MediaTracker mt=new MediaTracker(comp);
mt.addImage(img, 0);
try{
mt.waitForAll();
}catch(InterruptedException e){
System.err.println(e.toString());
}
}
public void draw(Graphics2D g, Component comp){
g.drawImage(img, AffineTransform.getTranslateInstance(x, y), comp);
/*Ellipse2D.Double e=new Ellipse2D.Double(x+2, y, w, h/3);
g.setColor(new Color(200, 100, 100));
g.fill(e);
Ellipse2D.Double em=new Ellipse2D.Double(x, y+4, w, h-(h/3));
g.setColor(new Color(0, 200, 0));
g.fill(em);*/
}
}
Danke schonmal...
Campino