Animation for divider movement in JSplitPane

大兔子大兔子 提交于 2019-12-10 20:29:47

问题


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.


回答1:


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.

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.



来源:https://stackoverflow.com/questions/9255646/animation-for-divider-movement-in-jsplitpane

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!