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


基础教程推荐
- 验证是否调用了所有 getter 方法 2022-01-01
- 大摇大摆的枚举 2022-01-01
- 不推荐使用 Api 注释的描述 2022-01-01
- Java 实例变量在两个语句中声明和初始化 2022-01-01
- 从 python 访问 JVM 2022-01-01
- Java Swing计时器未清除 2022-01-01
- 多个组件的复杂布局 2022-01-01
- 在 Java 中创建日期的正确方法是什么? 2022-01-01
- 如何在 Spring @Value 注解中正确指定默认值? 2022-01-01
- 如何在 JFrame 中覆盖 windowsClosing 事件 2022-01-01