j'essai d'afficher un tableView contenant des boutons, dont chaque ligne est un objet thread, mais je reçoit l'erreur
Not on FX application thread; currentThread = Thread-4
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
 
Runnable serverTask = () -> {
 
                try {
                    srv = new ServerSocket(Integer.valueOf(txtPort.getText()));
 
 
                    for (int i = 0; i < nbrParticipants; i++) {
                        //un nouveau thread participant 
                        Participant Ui;         
                        socket = srv.accept();
                        JFXButton btn = new JFXButton();
                        Ui = new Participant(nonce, socket, "Connecté...");
                        Ui.setButton(btn);
                        //ajouter le participant venu à la liste
                        participants.add(Ui);
 
 
                        //lancement du thread du nouveau participant
                        Thread thread = new Thread(Ui);
                        thread.start();
 
 
                        //rafraichir le tableau
                        fillTable();
                }                } catch (IOException e) {
                    e.printStackTrace();
                }
}
Thread serverThread = new Thread(serverTask);
serverThread.start();
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
 
public void fillTable() {
//convertir liste en ObservableList
connectedParticipants = FXCollections.observableArrayList(participants);
//ajouter une action au boutons
        for (int i = 0; i < connectedParticipants.size(); i++) {
            final int index = connectedParticipants.get(i).getId();
            connectedParticipants.get(i).getButton().setOnAction(new EventHandler<ActionEvent>(){
                @Override
                public void handle(ActionEvent event) {
                    receivePi(index);
                    calculateQiPoints(index);
                }
            });
        }
//code pour les autres colonnes et l'ajout au tableView
}
Merci