Java Swing的背景图片 [英] java swing background image

查看:132
本文介绍了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的背景图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆