您好,我正在尝试将桌面上的图像添加到我创建的 JFrame 中我的图像,但它在我的 drawImage 组件中导致错误,它要求一个图像观察者,我不知道它是什么,如果我自动填充一些我的图像没有出现在我的 JFrame 上。如果你们中的一个人可以查看我的代码或回答图像观察者的工作,我将不胜感激
public class Window2 extends JPanel {
// Image Import
ImageIcon i = new ImageIcon("C: / Class Pokemon Game/ src / GameTitle (1).psd");
Image title = i.getImage();
public void paintComponent(Graphics g)
{
super.paintComponent(g);
this.setBackground(Color.BLACK);
g.setColor(Color.RED);
g.fillRect(0, 40, 5000, 20);
g.**drawImage**(title, 500, 500);
}
}
错误是添加参数以匹配'drawImage(Image,int,int,ImageObserver)'