我想在相框上画一张照片,但是它不起作用,我找不到我的错误,请帮忙
import javax.swing.*;
import java.awt.*;
public class b1 extends JPanel {
Image img;
public b1() {
setFocusable(true);
ImageIcon u = new ImageIcon("C:/Benutzer/Julius/eclipse-workspace/JumpnRun/rsc/b1.jpg");
img = u.getImage();
}
public void paint(Graphics g) {
super.paintComponent(g);
Graphics2D f2 = (Graphics2D) g;
f2.drawImage(img, 0, 0, null);
}
}