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背景图片


基础教程推荐
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- 修改 void 函数的输入参数,然后读取 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01