我正在尝试创建虚拟桌面。我完成了successfully.But,我不能为jdesktoppane设置背景图像。我想设置背景图像和添加图像后,也桌面窗格的工作normally.Is任何人知道的方式只是告诉我,谢谢
发布于 2010-03-16 16:18:00
在this thread at coderanch中,一种可能的解决方案是在JDesktopPane的子类的paintComponent方法中绘制(或者在该类的渲染器中绘制,这可能会更好)。
发布于 2010-03-16 16:22:00
您可以使用另一个成员作为图像扩展JDeskTopPane类,然后在构造函数中设置该图像的背景。
public ExtendedJDesktopPane(Image image) {
super();
this.image = image;
}
protected void paintComponent(Graphics g) {
g.drawImage(scaledImage, 0, 0, this);
}编辑:这类似于Riduidel提供的下面的链接。我只是写得太晚了。
https://stackoverflow.com/questions/2452842
复制相似问题