Bonjour

dans un Panel,
je crée un Listener Interne,
puis je positionne un ecouteur sur deux combobox.
là j'obtiens un:
Erreur IHM : java.lang.NullPointerException

mon pbm vient du fait que le panel est instancié bien plus en amont dans la chaine et je veux pas y toucher. Je rajoute juste un filtre sur des groupes de courriers.

voici mon code
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
// ca c'est la liste qui affiche les courriers
  protected UTJInviteEntry typeDocIE;
// ca c'est la liste qui affiche les groupes
  protected UTJComboBoxKeyed groupeCourriersCbk;
// la dedans je stoque le choix du groupe
  protected static String groupeChoisi;
 
  public CreationCourrierPanel(ActionPanel action, FunctionFrame frame) {
    super(action, frame);
    communConstructor();
  }
  protected void communConstructor() {
    // construction IHM
    try  {
      initIHM();
    }
    catch(Exception e) {
      System.err.println("Erreur IHM : " + e);
      e.printStackTrace();
    }
  }
 
  protected void initIHM() throws Exception {
    // personnalisation des composants //
    this.detailPanel.setBordered();
    this.typeDocL.setText("Type document  : ");
    this.dateReceptionL.setText("Date réception : ");
    this.motifCb = new UTJComboBoxKeyed(MotifEvenement.getListeMotifVisible(), UTJComboBoxKeyed.STRING_EDITOR, 1, 20);
// G - remplissage de la combo des groupes 
    this.groupeCourriersCbk = new UTJComboBoxKeyed(GroupeCourrierEvenement.getListeGroupesCourriers(), UTJComboBoxKeyed.STRING_EDITOR, 5, 40);
    groupeCourriersCbk.setSelectedItem((String)groupeCourriersCbk.getSelectedKey());
//  pose ecouteur sur Combo groupe : il stocke la modif sur le code groupe
    this.groupeCourriersCbk.addActionListener( 
			new ActionListener() {
				public void actionPerformed(ActionEvent e){
				    groupeCourriersCbk.setSelectedItem((String)groupeCourriersCbk.getSelectedKey());
				    groupeChoisi = (String)groupeCourriersCbk.getSelectedKey();
				}
			}
    );
//  pose ecouteur sur liste des courriers : il raffraichit la liste des courriers
    this.typeDocIE.addActionListener( 
    		new ActionListener() {
    			public void actionPerformed(ActionEvent e){
// Construction invite type de document :
    				String[] columnNames = {"Code", "Libelle"};
    				int[] types = {UTJTable.TYPE_ALPHA, UTJTable.TYPE_ALPHA};
    				int[] taillesColonnes = {5,40};
    				int[] decim = {0,0};
    				int[] aligns = {SwingConstants.LEFT, SwingConstants.LEFT};
    				boolean[] zeroesView = {false, false};
    				UTJTable table = new UTJTable(columnNames, types, taillesColonnes, decim, aligns, zeroesView);
 
    				typeDocIE = new UTJInviteEntry("Choix du type de document", table,
    						TypeDocument.getListeDocumentsParGroupe(groupeChoisi), 0, 1, new UTKeyedItemString());
 
					String[] fieldsNamesOfKey = {"BKCOTYDOCU"};
    				typeDocIE.setFieldsNamesOfKey(fieldsNamesOfKey);
    			    typeDocIE.setItemEntry(new UTKeyedItemString(getTypeDocument(), ""));
    			}
    		}
    );
...
ma question est donc peut on avoir 2 ecouteurs issus d'un meme ListenerInterne dans une Vue ?