If you have a ListView where you add new items permanently (e.g. in a log viewer), the current visible items moves slowly out of the visible area.
If you start the example below the list is filled with the first items and nothing changes except for the scroll bar.
After you moved somewhere to the list's middle you can see the items scrolling down.
If you move to the end of the list it scrolls to a new items automatically, thus moving out the current items quickly.
The last behavior may be intentional, but it's not consistent.
package sample;
import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.ListView;
import javafx.stage.Stage;
import javafx.util.Duration;
public class ListViewScrollSample extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage stage) throws Exception {
ListView<String> listView = new ListView<>();
Timeline timeline = new Timeline(10, new KeyFrame(Duration.millis(10), evt -> {listView.getItems().add("line " + listView.getItems().size());}));
timeline.setCycleCount(Timeline.INDEFINITE);
timeline.play();
stage.setScene(new Scene(listView, 200, 400));
stage.show();
}
}
If you start the example below the list is filled with the first items and nothing changes except for the scroll bar.
After you moved somewhere to the list's middle you can see the items scrolling down.
If you move to the end of the list it scrolls to a new items automatically, thus moving out the current items quickly.
The last behavior may be intentional, but it's not consistent.
package sample;
import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.ListView;
import javafx.stage.Stage;
import javafx.util.Duration;
public class ListViewScrollSample extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage stage) throws Exception {
ListView<String> listView = new ListView<>();
Timeline timeline = new Timeline(10, new KeyFrame(Duration.millis(10), evt -> {listView.getItems().add("line " + listView.getItems().size());}));
timeline.setCycleCount(Timeline.INDEFINITE);
timeline.play();
stage.setScene(new Scene(listView, 200, 400));
stage.show();
}
}