创建一个不错的" LOADING ..."动画 [英] Creating a nice "LOADING..." animation

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

问题描述

可能重复:结果
   pretty替代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.

我想避免使用典型的进度,并使用像这样的一个漂亮的现代化无限进步

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?

推荐答案

我推荐使用的glassPane这种类型的活动。涉及的步骤如下:

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


  • 创建一个的JComponent 的BorderLayout 。添加的JLabel 中心,其中包括您所选择的.gif动画图标。

  • (可选)重写油漆(图形)方法,使您的GUI显示灰色(或粉饰出来)。为了实现这一点,你需要绘制一个填充矩形的组件的大小,填充用半透明的颜色的长方形。

  • 添加组件,为您的应用程序的根帧的glassPane。

  • 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.

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

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