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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
| public class X implements Initializable {
@FXML
private AnchorPane anchorPane;
@FXML
private Button btnValider;
@FXML
private ComboBox<String> comboBox1;
@FXML
private ComboBox<String> comboBox2;
@FXML
private TableColumn<Y, String> tableColumn1;
@FXML
private TableColumn<Y, String> tableColumn2;
@FXML
private TableColumn<Y, String> tableColumn3;
@FXML
private TableView<Y> tvTable;
private static ObservableList<Y> listeAjout = FXCollections.observableArrayList();
@FXML
void ajouterY(ActionEvent event) {
listeAjout.add(new Y(comboBox1.getSelectionModel().getSelectedItem()+" - "+comboBox2.getSelectionModel().getSelectedItem(), comboBox1.getSelectionModel().getSelectedItem(),comboBox2.getSelectionModel().getSelectedItem()));
tvTable.setItems(listeAjout);
}
@FXML
public void initialize(URL arg0, ResourceBundle arg1) {
assert anchorPane != null : "fx:id=\"anchorPane\" was not injected: check your FXML file 'x.fxml'.";
assert btnValider != null : "fx:id=\"btnValider\" was not injected: check your FXML file 'x.fxml'.";
assert tableColumn1 != null : "fx:id=\"tableColumn1\" was not injected: check your FXML file 'x.fxml'.";
assert comBox1 != null : "fx:id=\"comboBox1\" was not injected: check your FXML file 'x.fxml'.";
assert comBox2 != null : "fx:id=\"comboBox2\" was not injected: check your FXML file 'x.fxml'.";
assert tableColumn2 != null : "fx:id=\"tableColumn2\" was not injected: check your FXML file 'x.fxml'.";
assert tableColumn3 != null : "fx:id=\"tableColumn3\" was not injected: check your FXML file 'x.fxml'.";
assert tvTable != null : "fx:id=\"tvTable\" was not injected: check your FXML file 'x.fxml'.";
tableColumn1.setCellValueFactory(new PropertyValueFactory<Y, String>("denom"));
tableColumn2.setCellValueFactory(new PropertyValueFactory<Y, String>("ce"));
tableColumn3.setCellValueFactory(new PropertyValueFactory<Y, String>("cf"));
}
public static class Y {
private final SimpleStringProperty denom;
private final SimpleStringProperty ce;
private final SimpleStringProperty cf;
private Y(String denomination, String codeElement, String codeFinal) {
this.denom = new SimpleStringProperty(denomination);
this.ce = new SimpleStringProperty(codeElement);
this.cf = new SimpleStringProperty(codeFinal);
}
public String getDenomination() {
return denom.get();
}
public void setDenomination(String denomination) {
denom.set(denomination);
}
public String getCodeElement() {
return ce.get();
}
public void setCodeElement(String codeElement) {
ce.set(codeElement);
}
public String getCodeFinal() {
return cf.get();
}
public void setCodeFinal(String codeFinal) {
cf.set(codeFinal);
}
}
} |