java swing背景图片

java swing background image(java swing背景图片)

本文介绍了java swing背景图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 JFrame,并且在我的框架上保留了背景图像.现在的问题是图像的大小小于框架的大小,所以我必须在窗口的空白部分再次保留相同的图像.如果用户单击最大化按钮,我可能不得不在运行时将图像放在框架的空白区域.谁能告诉我如何做到这一点?

I am using JFrame and I have kept a background image on my frame. Now the problem is that the size of image is smaller then the size of the frame so i have to keep the same image once again on the empty part of the window. If user clicks maximize button than I may have to put the image on empty region of the frame at run time. Can anyone tell me how to accomplish this?

推荐答案

在多次使用背景图片而不是调整大小或仅居中显示时,您想要类似于 windows 桌面的背景图片?

You want something like the background image of the windows desktop, when using the background image multiple times instead of resizing it or just display it centered?

你只需要保存一次图像,然后在paintComponent方法中多次绘制.

You only have to keep the image once and just paint it multiple times in the paintComponent method.

这篇关于java swing背景图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:java swing背景图片