0

I have FXML file that has Pane as one of it's entries, used to show graph. It is not not visible by default. When checkbox is checked, the Pane is visible. Now I have to add graph in Pane and show graph when pane is visible. How to achieve this? I have created graph using this link. JavaFX real-time LineChart with time axis

Community
  • 1
  • 1
vishal
  • 309
  • 3
  • 6
  • 21
  • Can you be more precise about what exact behavior you want? Do you want to add the graph only once when the pane becomes visible for the first time, or do you want to remove the graph when the pane is hidden and add again when the pane is shown again? Would it be the same graph, or a new graph on each show? – Tomas Mikula Nov 27 '14 at 18:10
  • @TomasMikula I want to remove the graph when the pane is hidden and add again when the pane is shown again. Graph will be same means LineChart graph, only values will be dyanmic.(Value of Xaxis). – vishal Nov 28 '14 at 05:32

1 Answers1

0
pane.visibleProperty().addListener((obs, wasVisible, isVisible) -> {
    if(isVisible) { // pane became visible, add the graph
        LineChart<X, Y> chart = ...;
        pane.getChildren().add(chart);
    } else { // pane became hidden, remove the graph
        pane.getChildren().clear();
    }
});
Tomas Mikula
  • 6,537
  • 25
  • 39