JavaFx 2.0: get TreeItems or nodes that are currently displayed on the screen

I have TreeView<TitledPane>and want to show only "unread" content TitledPane.

I would like to receive an event notification if the content is displayed on the screen TitledPane.

TitledPanehas expandedProperty(), so it crashed, but I don’t see anything to filter out TreeItems that are far from the TreeView and are not displayed.

Another potential way I was thinking about is to check the visibility of the node sitting in the TitledPane with visibleProperty, but this does not seem to work.

pane.visibleProperty().addListener(new EnhancedListener(pane));

private class EnhancedListener implements ChangeListener<Boolean>
{
    Node parent;
    EnhancedListener(Node parent)
    {
        this.parent = parent;
    }
    @Override
    public void changed(ObservableValue<? extends Boolean> arg0, 
                        Boolean arg1, Boolean arg2) {
        TitledPane p = (TitledPane) parent;
        System.out.println(((Label)p.getContent()).getText()+" " + arg2);
    } 
}

I am using JavaFX 2.0.3

+3
source share
1 answer

. JavaFX " ListView Visible" JavaFX " API" , , .

visibleProperty , , (, node node, node - visibleProperty true, ). , , .

ListView, TreeView, - , TreeView , "", .

VirtualFlow vf = ((VirtualFlow)((ListViewSkin)myList.getChildrenUnmodifiable().get(0)).getChildrenUnmodifiable().get(0));
System.out.println(vf.getFirstVisibleCell().getIndex()+", "+vf.getLastVisibleCell().getIndex());
+4

All Articles