Bonjour les amis.
J'ai rempli mon Arraylist comme suit :
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
	public static ArrayList<ArticleFourAS400> getListArticleFourAS400(){
		connexion = new BDConnectAS400();
		reception = new AddReception();
		String requette = "SELECT DISTINCT B33STFC.FTEFAL01.NARTEF, B33STFC.FTEFAL01.MDIREF, B33STFC.FTEFAL01.LARFEF,"+"" 
					 +" B33STFC.FTTBAL01.PXACTF, B33STFC.FTEFAL01.NFOUEF"+""
					+" FROM B33STFC.FTEFAL01, B33STFC.FTTBAL01 WHERE B33STFC.FTTBAL01.NARTTF = B33STFC.FTEFAL01.NARTEF AND"+"" 
					+" CRAYEF in ('205','208') FETCH FIRST 30 ROWS ONLY";		
 
		Statement state;
		ResultSet res;
		ArrayList<ArticleFourAS400> list = new ArrayList<ArticleFourAS400>();
 
		try{
			state = connexion.getInstance().createStatement();
			res = state.executeQuery(requette);
			while(res.next()){
				ArticleFourAS400 artFourAS400 = new ArticleFourAS400();
				artFourAS400.setNARTEF(res.getString(1));
				artFourAS400.setLARFEF(res.getString(3));
				artFourAS400.setPXACTF(res.getString(4));
				artFourAS400.setNFOUEF(res.getString(5));
				list.add(artFourAS400);
			}
			res.close();
			return list;
		}catch(SQLException e){
			e.printStackTrace();
		}
		return null;
et je voudrais filtrer cette ArrayList selon la sélection du combobox, et afficher le résultat dans une Table, alors j'ai fais ceci :
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
public JComboBox getComboFournisseur() {
        if (ComboFournisseur == null) {
            ComboFournisseur = new JComboBox();
            ComboFournisseur.setBounds(135, 130, 352, 22);
            ComboFournisseur.setSelectedIndex(-1);
            ComboFournisseur.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                  /** on recupere notre Fournisseurs ( stocker en temps que Object donc on le cast)*/
                    DAOFourEtNumero selectedFournisseur = (DAOFourEtNumero) ComboFournisseur.getSelectedItem();
                    /** tu affiche le nom et l'id du fournisseur */
                    TxtNumFourniss.setText(Integer.toString(selectedFournisseur.getId()));
                    txtNomFournisseur.setText(selectedFournisseur.getNomFour());
                    Object code = ComboFournisseur.getSelectedItem();
 
                    ArrayList<ArticleFourAS400> lister = DAOArticleFourAS400.getListArticleFourAS400();
                         for(ArticleFourAS400 myList : lister){
                    	        if(myList.getNFOUEF().equals("6739")) {                   	
                    		    Table.setModel(new ArticleFourAS400TableModel(lister));
                    		}else{Table.setModel(new ArticleFourAS400TableModel());
                    		}}}
            });
        }
        return ComboFournisseur;
    }
Malheuresement, ça ne fonctionne pas et j'ai ces lignes d'erreur :
Exception occurred during event dispatching:
java.lang.NullPointerException
at ci.dataService.ArticleFourAS400TableModel.getRowCount(ArticleFourAS400TableModel.java:46)
at javax.swing.JTable.getRowCount(JTable.java:2640)
at javax.swing.plaf.basic.BasicTableUI.createTableSize(BasicTableUI.java:1643)
at javax.swing.plaf.basic.BasicTableUI.getPreferredSize(BasicTableUI.java:1684)
...
Voici deux jours que je galère sur ce problème
Quelqu'un pour me donner un coup de main s'il vous plaît.
Merci d'avance et bonne et heureuse année à tous.