我正在研究javafx项目并且我遇到了这个问题我想显示来自我的数据库的数据和每个数据我想在不同的窗格中显示它所以我必须循环我的数据 这是我的代码
@FXML
private Pane pane;
@FXML
private Label lblusername;
@FXML
private Label lbldescription;
/**
* Initializes the controller class.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
IPublicationService ps = new PublicationService();
IMembreService ms = new MembreService();
List<Publication> lp = ps.getAll();
for (int i = 0; i < lp.size(); i++) {
// lp.get(i).getCreateur().getId() retourne id dde user
// getuser retroune un objet user
lblusername = new Label(ms.getUser(lp.get(i).getCreateur().getId()).getUsername());
lbldescription = new Label(lp.get(i).getDescription());
pane = new Pane();
pane.setLayoutX(14.0);
pane.setLayoutY(137.0);
pane.setPrefHeight(200.0);
pane.setPrefWidth(705.0);
pane.setStyle("-fx-background-color: darkgrey");
pane.getChildren().addAll(lblusername,lbldescription);
}