Anzeige ein ImageIcon

Ich bin versucht, ein Bild anzuzeigen, das auf einem JPanel. Ich bin mit einem ImageIcon für die Darstellung des Bildes, und das Bild ist im selben Verzeichnis wie die class-Datei. Allerdings wird das Bild nicht angezeigt werden, gibt es keine Fehler auftreten. Könnte jemand bitte helfen herauszufinden, was ist Los mit meinem code...

package ev;

import java.awt.Graphics;
import javax.swing.ImageIcon;
import javax.swing.JPanel;

public class Image extends JPanel {

    ImageIcon image = new ImageIcon("peanut.jpg");
    int x = 10;
    int y = 10;

    public void paintComponent(Graphics g) {
        super.paintComponent(g);
        image.paintIcon(this, g, x, y);
    }
}

InformationsquelleAutor user1058860 | 2012-04-10

Schreibe einen Kommentar