Last active
September 29, 2015 01:00
-
-
Save ryanjaeb/74685a002e2b402e7fac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OS: Windows 8.1 | |
JVM: 1.8.0_40 (25.40-b25 - amd64) | |
Before firePulse(): | |
Item count: 5 | |
First visible cell: null | |
Last visible cell: null | |
After firePulse(): | |
Item count: 5 | |
First visible cell: ListViewSkin$2@7820053f[styleClass=cell indexed-cell list-cell]'list-item-1' | |
Last visible cell: ListViewSkin$2@8be9262[styleClass=cell indexed-cell list-cell]'list-item-5' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.sun.javafx.scene.control.skin.VirtualFlow; | |
import com.sun.javafx.tk.Toolkit; | |
import javafx.application.Application; | |
import javafx.application.Platform; | |
import javafx.collections.ObservableList; | |
import javafx.scene.Node; | |
import javafx.scene.Scene; | |
import javafx.scene.control.IndexedCell; | |
import javafx.scene.control.ListView; | |
import javafx.stage.Stage; | |
public class FirePulseApplication extends Application { | |
@Override | |
public void start(Stage primaryStage) throws Exception { | |
printEnv(); | |
ListView<String> listView = new ListView<>(); | |
Scene scene = new Scene(listView, 200, 400); | |
primaryStage.setScene(scene); | |
primaryStage.show(); | |
for (int i = 1; i < 6; i++) { | |
listView.getItems().add("list-item-" + i); | |
} | |
System.out.println("Before firePulse():"); | |
printVisibleRowInfo(listView); | |
Toolkit.getToolkit().firePulse(); | |
System.out.println("After firePulse():"); | |
printVisibleRowInfo(listView); | |
Platform.exit(); | |
} | |
private void printVisibleRowInfo(ListView<?> listView) { | |
// Item count according to the list model | |
System.out.println(" Item count: " + listView.getItems().size()); | |
// Extract the VirtualFlow so it can be used to determine which | |
// list items are rendered in the scene. | |
ObservableList<Node> children = listView.getChildrenUnmodifiable(); | |
VirtualFlow<?> flow = (VirtualFlow<?>) children.get(0); | |
IndexedCell<?> firstCell = flow.getFirstVisibleCell(); | |
System.out.println(" First visible cell: " + firstCell); | |
IndexedCell<?> lastCell = flow.getLastVisibleCell(); | |
System.out.println(" Last visible cell: " + lastCell); | |
} | |
private void printEnv() { | |
String osName = System.getProperty("os.name"); | |
String jvm = System.getProperty("java.version") + | |
" (" + System.getProperty("java.vm.version") + | |
" - " + System.getProperty("os.arch") + ")"; | |
System.out.println("OS: " + osName); | |
System.out.println("JVM: " + jvm); | |
System.out.println(""); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment