JavaFX Pagination Demo

JavaFX Pagination control demo modified to run in Processing default window:

//https://jenkov.com/tutorials/javafx/pagination.html

import javafx.scene.canvas.Canvas;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.Pane;
import javafx.scene.control.Pagination;
import javafx.scene.control.Label;
import javafx.scene.text.Font;

Canvas canvas;
StackPane root;
int pageIndex = 0;

void setup() {
  size(600, 600, FX2D);
  surface.setTitle("JavaFX Pagination Demo");
  canvas = (Canvas)surface.getNative();
  root = (StackPane)canvas.getParent();
  Pagination pagination = new Pagination();
  pagination.setPageCount(21);
  pagination.setCurrentPageIndex(0);
  pagination.setMaxPageIndicatorCount(3);
  pagination.setPageFactory((pageIndex) -> {
    Label label = new Label("Content for page with index: " + str(pageIndex+1));
    label.setLayoutX(30);
    label.setFont(new Font("Arial", 20));
    return new Pane(label);
  }
  );
  root.getChildren().add(pagination);
}

Output:

1 Like