I have a list, each element of which has several things in it, including JProgressBarone that can update a lot. Each time one of the elements updates its own JProgressBar, it ListDataListenertries to scroll its visible range in the list using
public void contentsChanged(final ListDataEvent evt) {
if (!EventQueue.isDispatchThread()) {
EventQueue.invokeLater(new Runnable() {
public void run() {
contentsChanged(evt);
}
});
}
if (playbackInProgress) {
int index = evt.getIndex0();
currentContentList.ensureIndexIsVisible(index);
}
}
Please note that I am trying to make sure that scrolling is done in the send thread, since I thought the problem was that it scrolls while it is being repainted. And still, I still have a problem when, if something is really active, some elements of the list are painted outside the viewport, overwriting what is outside JScrollPane. Forcing an exposure event will recolor these things, but it is annoying.
- , , ?