Bonjour,
j'ai déjà eu posé des questions, mais je suis toujours bloqué sur la meme question : comment faire pour afficher ma liste dans ma listeView en ayant un pattern strategie. Merci ...

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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
 
public class Musique {
 
    private final IntegerProperty id = new SimpleIntegerProperty();
    public int getId() {return id.get();} public void setId(int value) {id.set(value);}
    public IntegerProperty idProperty() {return id;}
 
    private final StringProperty titre = new SimpleStringProperty();
    public String getTitre() {return titre.get();}
    public void setTitre(String value) {titre.set(value);}
    public StringProperty titreProperty() {return titre;}
 
    private final StringProperty artiste = new SimpleStringProperty();
    public String getArtiste() {return artiste.get();}
    public void setArtiste(String value){artiste.set(value);}
    public StringProperty artisteProperty() {return artiste;}
 
    private final StringProperty duree = new SimpleStringProperty();
    public String getDuree() {return duree.get();}
    public void setDuree(String value) {duree.set(value);}
    public StringProperty dureeProperty() { return duree;}
 
 
    public Musique(Integer id, String titre, String artiste, String duree){
        this.id.set(id);
        this.titre.set(titre);
        this.artiste.set(artiste);
        this.duree.set(duree);
 
    }
 
public class ListeMusique {
 
    DataManager dm;
 
    ObservableList<Musique> lesMusiquesObservables = FXCollections.observableArrayList();
 
    private final ListProperty<Musique> lesMusiques = new SimpleListProperty<>(lesMusiquesObservables);
        public ObservableList<Musique> getLesMusiques() {return lesMusiques.get();}
        public void setLesMusiques(ObservableList<Musique> value) {lesMusiques.set(value);}
        public ListProperty<Musique> lesMusiquesProperty() {return lesMusiques;}
 
 
    /*public ListeMusique(ListProperty<Musique> nouvelleListe){
               lesMusiques.set(nouvelleListe.get());
    }*/
 
public  class DataManager {
 
   MusiqueManager mg = new MusiqueManager() {
       @Override
       public List<Musique> lireMusique() {
           throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
       }
   };
 
   public List<Musique> lireMusique()
   {
       return mg.lireMusique();
   }
 
public abstract class MusiqueManager{
 
public abstract List<Musique> lireMusique();
}
 
public class MusiqueDur extends MusiqueManager{
 
    @Override
    public List<Musique> lireMusique(){
                ArrayList<Musique> listeTemporaire = new ArrayList();
                listeTemporaire.add(new Musique(3, "Ceci est un essai", "Toto", "5m10"));
                return listeTemporaire;
    }
}
 
 
public class FXMLDocumentController implements Initializable {
 
    @FXML
    private void addMusique() throws IOException{
        Parent root = FXMLLoader.load(getClass().getResource("/View/AjouterMusique.fxml"));
 
        Scene scene = new Scene(root);
        Stage stage = new Stage();
        stage.setScene(scene);
        stage.setTitle("Ajouter Une Musique");
        stage.show();
    }
 
 
 
    @FXML
    private void quitterAppli() throws IOException{
        Platform.exit();
    }
    @FXML
    Button closebutton;
 
     @FXML
    private void quitterWindow() throws IOException{
     Stage stage = (Stage) closebutton.getScene().getWindow();
     stage.close();
    }
 
    @FXML
    ListView<Musique> lesMusiques;
 
    //@FXML 
    ListeMusique listeMusiques = new ListeMusique();
 
    @Override
    public void initialize(URL url, ResourceBundle rb) {
       lesMusiques.itemsProperty().bind(listeMusiques.lesMusiquesProperty());
    }    
 
}
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
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<?xml version="1.0" encoding="UTF-8"?>
 
<?import javafx.scene.image.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.media.*?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import Model.*?>
 
 
<AnchorPane fx:id="anchorpane" prefHeight="400.0" prefWidth="600.0" stylesheets="@style.css" 
            xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" 
            fx:controller="Controller.FXMLDocumentController">
 
    <!--<fx:define>
        <ListeMusique fx:id="listeMusiques"/>
    </fx:define>-->
 
   <children>
      <VBox prefHeight="400.0" prefWidth="600.0">
         <children>
            <MenuBar fx:id="menuBar">
              <menus>
                <Menu fx:id="File" mnemonicParsing="false" text="File">
                  <items>
                    <MenuItem mnemonicParsing="false" text="Ajouter Musique" />
                    <MenuItem mnemonicParsing="false" text="Supprimer Musique" />
                    <MenuItem mnemonicParsing="false" onAction="#quitterAppli" text="Close" />
                  </items>
                </Menu>
                <Menu mnemonicParsing="false" text="Edit">
                  <items>
                    <MenuItem mnemonicParsing="false" text="Musique Suivante" />
                    <MenuItem mnemonicParsing="false" text="Musique Precedente" />
                  </items>
                </Menu>
                <Menu mnemonicParsing="false" text="Help">
                  <items>
                    <MenuItem mnemonicParsing="false" text="About">
                           </MenuItem>
                  </items>
                </Menu>
              </menus>
            </MenuBar>
            <GridPane prefHeight="375.0" prefWidth="600.0">
              <columnConstraints>
                <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
              </columnConstraints>
              <rowConstraints>
                <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
                <RowConstraints maxHeight="67.0" minHeight="10.0" prefHeight="58.0" vgrow="SOMETIMES" />
                  <RowConstraints maxHeight="209.0" minHeight="10.0" prefHeight="202.0" vgrow="SOMETIMES" />
                  <RowConstraints maxHeight="86.0" minHeight="0.0" prefHeight="0.0" vgrow="SOMETIMES" />
              </rowConstraints>
               <children>
                  <GridPane GridPane.rowIndex="2">
                    <columnConstraints>
                      <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
                      <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
                    </columnConstraints>
                    <rowConstraints>
                      <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
                    </rowConstraints>
                     <children>
                        <ListView prefHeight="190.0" prefWidth="261.0" fx:id="lesMusiques" items="${listeMusiques.lesMusiques}">
                           <GridPane.margin>
                              <Insets bottom="20.0" left="20.0" right="20.0" top="20.0" />
                           </GridPane.margin>
                        </ListView>
                        <Label prefHeight="221.0" prefWidth="303.0" GridPane.columnIndex="1">
                           <GridPane.margin>
                              <Insets bottom="20.0" left="20.0" right="20.0" top="20.0" />
                           </GridPane.margin>
                           <graphic>
                              <GridPane prefHeight="169.0" prefWidth="258.0">
                                <columnConstraints>
                                  <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
                                  <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
                                </columnConstraints>
                                <rowConstraints>
                                    <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
                                  <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
                                  <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
                                  <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
                                    <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
                                </rowConstraints>
                                 <children>
                                    <Button mnemonicParsing="false" GridPane.columnIndex="1" GridPane.rowIndex="4">
                                       <graphic>
                                          <ImageView fitHeight="22.0" fitWidth="54.0" pickOnBounds="true" preserveRatio="true">
                                             <image>
                                                <Image url="@play.jpg" />
                                             </image>
                                          </ImageView>
                                       </graphic>
                                    </Button>
                                    <Label fx:id="Titre" text="Titre" />
                                    <Label fx:id="Artiste" text="Artiste" GridPane.rowIndex="1" />
                                    <Label fx:id="Categorie" text="Categorie" GridPane.rowIndex="2" />
                                    <Label fx:id="Duree" text="Durée" GridPane.rowIndex="3" />
                                    <Label fx:id="Lecture" text="Lecture" GridPane.rowIndex="4" />
                                    <Label text="Yo je suis la" GridPane.columnIndex="1" />
                                    <Label text="Mc afi" GridPane.columnIndex="1" GridPane.rowIndex="1" />
                                    <Label text="Electro" GridPane.columnIndex="1" GridPane.rowIndex="2" />
                                    <Label text="3m10" GridPane.columnIndex="1" GridPane.rowIndex="3" />
                                 </children>
                              </GridPane>
                           </graphic>
                        </Label>
                     </children>
                  </GridPane>
                  <GridPane>
                    <columnConstraints>
                      <ColumnConstraints hgrow="SOMETIMES" maxWidth="437.0" minWidth="10.0" prefWidth="437.0" />
                      <ColumnConstraints hgrow="SOMETIMES" maxWidth="294.0" minWidth="10.0" prefWidth="163.0" />
                    </columnConstraints>
                    <rowConstraints>
                      <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
                    </rowConstraints>
                     <children>
                        <Label alignment="CENTER" prefHeight="17.0" prefWidth="434.0" text="Ici defilera le titre de la chanson" />
                        <HBox prefHeight="100.0" prefWidth="200.0" GridPane.columnIndex="1">
                           <children>
                              <Button fx:id="BouttonPlay" mnemonicParsing="false" opacity="0.73">
                                 <HBox.margin>
                                    <Insets right="20.0" />
                                 </HBox.margin>
                                 <graphic>
                                    <ImageView fitHeight="23.0" fitWidth="42.0" pickOnBounds="true" preserveRatio="true">
                                       <image>
                                          <Image url="@play.jpg" />
                                       </image>
                                    </ImageView>
                                 </graphic>
                              </Button>
                              <Button mnemonicParsing="false">
                                 <graphic>
                                    <ImageView fitHeight="21.0" fitWidth="32.0" pickOnBounds="true" preserveRatio="true">
                                       <image>
                                          <Image url="@pause.jpg" />
                                       </image>
                                    </ImageView>
                                 </graphic></Button>
                           </children>
                           <GridPane.margin>
                              <Insets bottom="20.0" left="20.0" right="20.0" top="20.0" />
                           </GridPane.margin>
                        </HBox>
                     </children>
                  </GridPane>
                  <HBox prefHeight="100.0" prefWidth="200.0" GridPane.rowIndex="1">
                     <children>
                        <ComboBox prefWidth="150.0" promptText="Categorie">
                           <HBox.margin>
                              <Insets left="20.0" right="150.0" top="20.0" />
                           </HBox.margin>
                        </ComboBox>
                        <TextField opacity="0.77" promptText="Rechercher">
                           <HBox.margin>
                              <Insets top="20.0" />
                           </HBox.margin>
                        </TextField>
                     </children>
                  </HBox>
               </children>
            </GridPane>
         </children>
      </VBox>
   </children>
</AnchorPane>
Merci beaucoup