java swing background image(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背景图片
基础教程推荐
- 在springboot中如何给mybatis加拦截器 2023-04-29
- 如何在相机中应用自定义滤镜 [Surfaceview 预览]. 2022-01-01
- 在java中使用xpath和selenium解析HTML表格数据 2022-01-01
- Java ECDSAwithSHA256 签名长度不一致 2022-01-01
- 将 double 转换为 Int,向下舍入 2022-01-01
- doFilter()是在servlet的工作完成之前还是之后执行的? 2022-01-01
- 将 Windows 证书导入 Java 2022-01-01
- Maven:无效的目标版本:10 2022-01-01
- 控制台应用程序中的 Java 键盘输入解析 2022-01-01
- JPA惰性列表上的流 2022-01-01
