java - ListView.scrollTo works slow with huge number of items -
the scrollto method in code below works slow. there way speed or may alternative variant? need display 100000 items in application. there alternative components. thanks.
import java.util.arraylist; import java.util.list; import java.util.uuid; import javafx.application.application; import javafx.collections.fxcollections; import javafx.event.actionevent; import javafx.event.eventhandler; import javafx.scene.scene; import javafx.scene.control.button; import javafx.scene.control.listview; import javafx.scene.layout.stackpane; import javafx.scene.layout.vbox; import javafx.stage.stage; public class main extends application { public static void main(string[] args) { launch(args); } @override public void start(stage stage) throws exception { final listview<string> listview = new listview<>(); button button = new button("goto"); button.setonaction(new eventhandler<actionevent>() { @override public void handle(actionevent event) { int = 99998; system.out.println("before scroll"); long starttime = system.currenttimemillis(); listview.scrollto(i); long elapsedtime = system.currenttimemillis() - starttime; system.out.println(elapsedtime); listview.getfocusmodel().focus(i); } }); list<string> items = new arraylist<>(); (int = 0; < 100000; i++) { items.add(uuid.randomuuid().tostring()); } listview.setitems(fxcollections.observablearraylist(items)); stackpane pane = new stackpane(); vbox vbox = new vbox(); vbox.getchildren().add(button); vbox.getchildren().add(listview); pane.getchildren().add(vbox); stage.setscene(new scene(pane)); stage.show(); } }
Comments
Post a Comment