在我的代码中,UI 具有以下组件:
JSplitPane:
pane1: JTable
pane2: JPanel with some texutal information.
我正在监听表格上的行选择事件,然后适本地设置拆分 Pane 的分隔符位置,以便文本信息对某些行可见而对其他一些行隐藏。
但是,这种方法的一个问题是切换到分隔线位置非常突然,这让用户很少有时间了解发生了什么。
能否请您告诉我如何添加一些动画,以便分隔符位置切换缓慢进行,并让用户知道文本信息针对特定行选择显示,而针对其他行选择隐藏。
最佳答案
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
控制动画,如图所示 example .请注意,在调整框架大小时,动画保持流畅。
关于java - JSplitPane 中分隔线移动的动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9255646/