创建一个不错的“正在加载..."动画片 [英] Creating a nice "LOADING..." animation

查看:32
本文介绍了创建一个不错的“正在加载..."动画片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能的重复:
JProgressBar 的替代品?

我有一个需要几秒钟才能加载的进程,我想在 Java Swing 中创建一个动画,直到它完成加载.

I have a process which takes several seconds to load, and I want to create an animation in Java Swing until it finishes loading.

我想避免使用典型的 ProgressBar 并使用像这样的现代无限进度

I'd like to avoid using a typical ProgressBar and use a nice modern infinite progress like this one

我知道类似的问题,但这与 Java Swing 严格相关.是否有任何图书馆或示例?

I'm aware of similar questions but this is strictly Java Swing related. Is there any library or example for this?

推荐答案

对于此类活动,我建议使用玻璃板.涉及的步骤是:

I'd recommend using the glasspane for this type of activity. The steps involved are:

  • 使用 BorderLayout 创建一个 JComponent.将 JLabel 添加到 CENTER,其中包含您选择的动画 .gif 图标.
  • (可选)覆盖 paint(Graphics) 方法,使您的 GUI 显示为灰色(或白色).为此,您需要绘制一个与组件大小相同的填充矩形,并使用半透明颜色填充该矩形.
  • 将该组件添加为应用程序根框架的玻璃窗格.
  • Create a JComponent with BorderLayout. Add a JLabel to the CENTER which includes the animated .gif icon of your choice.
  • (Optional) Override the paint(Graphics) method to make your GUI appear greyed out (or whited out). To achieve this you need to draw a filled rectangle the size of the component, filling the rectangle with a semi-transparent Color.
  • Add the component as the glasspane of your application's root frame.

这篇关于创建一个不错的“正在加载..."动画片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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