title: Add progress bar in JavaFX table pagination
body: <p>I have this example of JavaFX table.</p>
  
  <pre><code>    import java.util.ArrayList;
  import java.util.List;
  import javafx.application.Application;
  import javafx.beans.property.SimpleObjectProperty;
  import javafx.beans.property.SimpleStringProperty;
  import javafx.beans.value.ObservableValue;
  import javafx.collections.FXCollections;
  import javafx.scene.Node;
  import javafx.scene.Scene;
  import javafx.scene.control.Pagination;
  import javafx.scene.control.TableColumn;
  import javafx.scene.control.TableView;
  import javafx.scene.layout.BorderPane;
  import javafx.stage.Stage;
  
  public class MainApp extends Application
  {
  
      private final static int dataSize = 10_023;
      private final static int rowsPerPage = 1000;
  
      private final TableView&lt;Sample&gt; table = createTable();
      private final List&lt;Sample&gt; data = createData();
  
      private List&lt;Sample&gt; createData()
      {
          List&lt;Sample&gt; data = new ArrayList&lt;&gt;(dataSize);
  
          for (int i = 0; i &lt; dataSize; i++)
          {
              data.add(new Sample(i, "foo " + i, "bar " + i));
          }
  
          return data;
      }
  
      private TableView&lt;Sample&gt; createTable()
      {
  
          TableView&lt;Sample&gt; table = new TableView&lt;&gt;();
  
          TableColumn&lt;Sample, Integer&gt; column1 = new TableColumn&lt;&gt;("Id");
          column1.setCellValueFactory(param -&gt; param.getValue().id);
          column1.setPrefWidth(150);
  
          TableColumn&lt;Sample, String&gt; column2 = new TableColumn&lt;&gt;("Foo");
          column2.setCellValueFactory(param -&gt; param.getValue().foo);
          column2.setPrefWidth(250);
  
          TableColumn&lt;Sample, String&gt; column3 = new TableColumn&lt;&gt;("Bar");
          column3.setCellValueFactory(param -&gt; param.getValue().bar);
          column3.setPrefWidth(250);
  
          table.getColumns().addAll(column1, column2, column3);
  
          return table;
      }
  
      private Node createPage(int pageIndex)
      {
  
          int fromIndex = pageIndex * rowsPerPage;
          int toIndex = Math.min(fromIndex + rowsPerPage, data.size());
          table.setItems(FXCollections.observableArrayList(data.subList(fromIndex, toIndex)));
  
          return new BorderPane(table);
      }
  
      @Override
      public void start(final Stage stage) throws Exception
      {
  
          Pagination pagination = new Pagination((data.size() / rowsPerPage + 1), 0);
          pagination.setPageFactory(this::createPage);
  
          Scene scene = new Scene(new BorderPane(pagination), 1024, 768);
          stage.setScene(scene);
          stage.setTitle("Table pager");
          stage.show();
      }
  
      public static void main(String[] args) throws Exception
      {
          launch(args);
      }
  
      public static class Sample
      {
  
          private final ObservableValue&lt;Integer&gt; id;
          private final SimpleStringProperty foo;
          private final SimpleStringProperty bar;
  
          private Sample(int id, String foo, String bar)
          {
              this.id = new SimpleObjectProperty&lt;&gt;(id);
              this.foo = new SimpleStringProperty(foo);
              this.bar = new SimpleStringProperty(bar);
          }
      }
  }
  </code></pre>
  
  <p>Is there a way to add Progress bar when pages are switched and data is loaded?</p>
  
  <p>It's not very clear how I can use progress indicator while data is loaded.</p>
  
  <p>Is there any useful example?</p>