【发布时间】:2012-08-24 01:17:58
【问题描述】:
如果 paint() 方法已用于其他目的,我如何在 JPanel 中使用图像作为背景? (我试图在面板中绘制图像)。
这是我用铅笔画的代码,但我不知道如何将图像添加为背景?
@Override
public void paint(Graphics g) {
if (x >= 0 && y >= 0) {
g.setColor(Color.BLACK);
g.fillRect(x, y, 4, 4);
}
}
谢谢迭戈
【问题讨论】: