简体   繁体   中英

JavaFX FXML - How to show a collection in a GridPane with pagination?

I have the following GridPane in FXML:

(This code was generated by JavaFX Scene Builder)

<GridPane fx:id="gridUsers" alignment="TOP_CENTER" layoutX="13.0" layoutY="161.0" prefWidth="763.0">
  <children>
    <Label fx:id="codigoUsuarioLabel" text="Code" GridPane.columnIndex="0" GridPane.rowIndex="0">
      <font>
        <Font name="System Bold" size="18.0" fx:id="x2" />
      </font>
    </Label>
    <Label fx:id="userNameLabel" font="$x2" text="Name" GridPane.columnIndex="1" GridPane.rowIndex="0" />
    <Label fx:id="loginUserLabel" font="$x2" text="Login" GridPane.columnIndex="2" GridPane.rowIndex="0" />
    <Label fx:id="userOptionsLabel" font="$x2" text="Options" GridPane.columnIndex="3" GridPane.rowIndex="0" />
  </children>
  <columnConstraints>
    <ColumnConstraints hgrow="SOMETIMES" maxWidth="308.0" minWidth="10.0" prefWidth="102.0" />
    <ColumnConstraints hgrow="SOMETIMES" maxWidth="482.0" minWidth="0.0" prefWidth="318.0" />
    <ColumnConstraints hgrow="SOMETIMES" maxWidth="244.0" minWidth="10.0" prefWidth="244.0" />
    <ColumnConstraints hgrow="SOMETIMES" maxWidth="100.0" minWidth="10.0" prefWidth="100.0" />
  </columnConstraints>
  <rowConstraints>
    <RowConstraints maxHeight="30.0" minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
    <RowConstraints maxHeight="30.0" minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
  </rowConstraints>
</GridPane>

In my UserController, I have a collection with the User objects. I want to pass this collection from the Controller to the GridPane and list the objects, preferably with pagination.

How can I do this?

If you can use JavaFX 2.2 +, this version of JavaFX has a built-in Pagination control which can provide. Otherwise you will need to write such a functionality yourself or backport the control from the 2.2 open source repository into your code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM