Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top