1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
public void addToGridPane(Label nomArticle,Label prixArticle) {
GridPane gridPane=new GridPane();
//gridPane.setGridLinesVisible(true);
gridPane.add(nomArticle,0,compteurLigneGridPane);
gridPane.setConstraints(prixArticle,1,compteurLigneGridPane,1,1,HPos.CENTER,VPos.CENTER);
gridPane.add(prixArticle,1,compteurLigneGridPane);
ColumnConstraints col1=new ColumnConstraints();
col1.setPercentWidth(75);
ColumnConstraints col2=new ColumnConstraints();
col2.setPercentWidth(25);
gridPane.getColumnConstraints().addAll(col1,col2);
gridPane.setVgap(40);
gridPane.setMaxWidth(200);
gridPane.setOnMouseClicked(event -> {
Node intersectedNode = event.getPickResult().getIntersectedNode();
Integer removableRowIndex = GridPane.getRowIndex(intersectedNode);
gridPane.getChildren().removeIf(node -> GridPane.getRowIndex(node) == removableRowIndex);
compteurLigneGridPane--;
});
/*gridPane.setOnMouseClicked(event -> {
gridPane.getChildren().removeAll(nomArticle,prixArticle);
compteurLigneGridPane--;
});*/
anchorPaneCommande.setRightAnchor(gridPane,5.0);
anchorPaneCommande.setLeftAnchor(gridPane,5.0);
anchorPaneCommande.getChildren().add(gridPane);
compteurLigneGridPane++;
} |
Partager