How to create a pagination using JavaFX?

JavaFXObject Oriented ProgrammingProgramming

Pagination divides content up between pages and allows users to skip between pages or go in order through the content. You can create pagination by instantiating the javafx.scene.control.Pagination class.

Example

The following Example demonstrates the creation of a Pagination.

import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Pagination;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
public class PaginationExample extends Application {
   public void start(Stage stage) {
      //Creating a pagination
      Pagination pagination = new Pagination();
      //Setting number of pages
      pagination.setPageCount(10);
      //Creating a vbox to hold the pagination
      VBox vbox = new VBox();
      vbox.setSpacing(5);
      vbox.setPadding(new Insets(50, 50, 50, 60));
      vbox.getChildren().addAll(pagination);
      //Setting the stage
      Group root = new Group(vbox);
      Scene scene = new Scene(root, 595, 200, Color.BEIGE);
      stage.setTitle("Pagination");
      stage.setScene(scene);
      stage.show();
   }
   public static void main(String args[]){
      launch(args);
   }
}

Output

raja
Published on 18-May-2020 11:31:41
Advertisements