如何在我的Java桌面应用程序中插入背景图像?

问题描述:

我想在我附加的应用程序中添加背景设置,但它不适合我。我附上了完整的源代码+我想如何在我的应用程序中使用背景的截图。谁能帮我这个?如何在我的Java桌面应用程序中插入背景图像?

截图

just an example

Source Code(具体GUI菜单)

+0

我没有源代码,对不起。 – Chiron

+0

请不要使用[link shorteners](http://meta.stackexchange.com/questions/113658/no-url-shorteners)或[签名](http://meta.stackexchange.com/questions/5029/) -taglines的签名,不允许)。请嵌入图片并尝试将代码缩减为[简短,自包含,正确的示例](http://sscce.org/),您可以将其包含为代码片段。 – Zong

我不会去通过所有源 - 但它听起来像你想设置背景图片在面板上。

你可以通过覆盖面板颜色代码来做到这一点。

@Override 
protected void paintComponent(Graphics grphcs) { 
    grphcs.drawImage(background, 0, 0, getWidth(), getHeight(), null); 
} 

其中的背景是:

private final Image background; 

,并在构造函数:

background = ImageIO.read(getClass().getResourceAsStream("FILENAME.jpg"));