Bonjour a tous,

J'ai un tableView alimenté et j'aimerais rendre un de ses champs modifiable.

J'ai modifié le FXML :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?xml version="1.0" encoding="UTF-8"?>
 
<?import java.lang.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.layout.AnchorPane?>
 
<AnchorPane prefHeight="299.0" prefWidth="309.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2" fx:controller="liste.Liste1Controller">
  <children>
    <TableView fx:id="tableView2" editable="true" prefHeight="400.0" prefWidth="600.0" AnchorPane.bottomAnchor="10.0" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="10.0">
      <columns>
        <TableColumn prefWidth="75.0" text="Numero" fx:id="Index" />
        <TableColumn editable="true" prefWidth="75.0" text="Type" fx:id="Type" />
        <TableColumn prefWidth="75.0" text="Categorie" fx:id="Categorie" />
        <TableColumn prefWidth="75.0" text="Nom" fx:id="Nom" />
      </columns>
    </TableView>
  </children>
</AnchorPane>
pour ajouter editable="true" sur le table view et la colonne.

J'ai modifié le Controller, mais la zone reste non modifiable.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
90
91
92
package liste;
 
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
import bean.Liste;
import bean.Type;
import fxmltableview.FxmlListe;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.value.ObservableValue;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.scene.control.MenuBar;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableColumn.CellDataFeatures;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.control.cell.TextFieldTableCell;
import javafx.util.Callback;
 
import menu.MenuManager;
 
/**
 * FXML Controller class
 *
 * @author Ordi
 */
public class Liste1Controller {
 
    @FXML
    private TableView<Type> tableView2;
    @FXML
    private TableColumn<Type, Integer> Index;
    @FXML
    private TableColumn<Type, String> Type;
    @FXML
    private TableColumn<Type, String> Categorie;
    @FXML
    private TableColumn<Type, String> Nom;
 
    private MenuManager menu;
 
    //private ObservableList<Liste> personData = FXCollections.observableArrayList();
    /**
     * The constructor. The constructor is called before the initialize()
     * method.
     */
    public Liste1Controller() {
 
    }
 
    /**
     * Initializes the controller class.
     */
    @FXML
    public void initialize() {
        tableView2.setEditable(true);
        Index.setCellValueFactory(new PropertyValueFactory<Type, Integer>("Index"));
        Type.setCellValueFactory(new Callback<CellDataFeatures<Type, String>, ObservableValue<String>>() {
            public ObservableValue<String> call(CellDataFeatures<Type, String> p) {
                return new SimpleStringProperty(p.getValue().getType());
            }
        });
        //Type.setCellValueFactory(new PropertyValueFactory<Type, String>("Type"));
        Categorie.setCellValueFactory(new PropertyValueFactory<Type, String>("Categorie"));
        Nom.setCellValueFactory(new PropertyValueFactory<Type, String>("Nom"));
 
    }
 
    public void initManager(final MenuManager menuManager) {
        this.menu = menuManager;
    }
 
    public void setMainApp(ObservableList<Type> mainApp) {
 
        // Add observable list data to the table
        tableView2.setItems(mainApp);
    }
 
    @FXML
    private void handleAboutQuit(final ActionEvent event) {
        System.exit(0);
    }
 
    public final void setOnEditCommit(EventHandler<TableColumn.CellEditEvent<Type, String>> value) {
 
    }
 
}
Je cherche pas encore à récupérer et stocker la nouvelle valeur, mais pour l'instant juste à cliquer sur un champs de la colonne Type pour la modifier.

Qu'ai-je loupé?