JSplitPane中分隔线运动的动画 [英] Animation for divider movement in JSplitPane

查看:140
本文介绍了JSplitPane中分隔线运动的动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的代码中,UI具有以下组件:

In my code, the UI has the following components:

JSplitPane:    
    pane1: JTable
    pane2: JPanel with some texutal information.

我正在侦听表上的行选择事件,然后适当地设置拆分窗格的分隔符位置,以使文本信息在某些行中可见,而在其他某些行中隐藏.

I am listening to the row selection events on the table and then setting the divider location of the splitpane appropriately so that the textual information is visible for some row and is hidden for some other rows.

但是,这种方法的一个问题是切换到分隔器的位置非常突然,这给了用户更少的时间来了解发生了什么.

However, one problem with this approach is the switching to the divider location is very abrupt which gives very less time to the user to understand what happened.

请让我知道如何添加一些动画,以便分隔符位置切换缓慢发生,并为用户提供以下信息:对于特定的行选择显示文本信息,而对于其他的行选择则隐藏文本信息.

Could you please let me know how to add in some animation so that the divider location switching happens slowly and gives user an idea that textual information is shown for a particular row selection and hidden for some other row selection.

推荐答案

我尝试在AWT线程上将除法器位置从一个值缓慢更改为另一个值,但是UI似乎无法正确响应.

I tried changing the divider location slowly from one value to the next on the AWT thread, but then the UI seemed to not respond properly.

使用 javax.swing.Timer 如以下示例所示,以控制动画.请注意,调整帧大小后,动画将保持平滑.

Use a javax.swing.Timer to control the animation, as shown in this example. Note that the animation remains smooth as the frame is resized.

这篇关于JSplitPane中分隔线运动的动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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