Bonjour,
J'ai écris un petit chat.. je tente d'y mettre des smileys , ils s'affichent bien lors de la selection , mais lorsqu'ils doivent s'afficher dans le JTextPane , ils ne s'affichent pas

Voici le code d'initialisation :
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
 
	   monEcran = new JTextPane()
	   {
           //Image grayImage = GrayFilter.createDisabledImage(image);
           {setOpaque(false);}
 
           public void paintComponent (Graphics g)
           {
               g.drawImage(image, 0, 0, (int)getSize().getWidth(), (int)getSize().getHeight(), this);
               //g.drawImage(grayImage, 0, 0, (int)getSize().getWidth(), (int)getSize().getHeight(), this);
               super.paintComponent(g);
           }
       };
       monEcran.setEditable(false);
       monEcran.setFocusable(false);
	   doc = monEcran.getStyledDocument();
 // DEFINITION DES DIFFERENTS STYLES (BOLD , ICON , REGULAR .. )
	   Style def = StyleContext.getDefaultStyleContext().
       getStyle(StyleContext.DEFAULT_STYLE);
       Style regular = doc.addStyle("regular", def);
       s = doc.addStyle("icon", regular);
       StyleConstants.setAlignment(s, StyleConstants.ALIGN_CENTER);
 
 
       if (monSmil != null) {
           StyleConstants.setIcon(s, monSmil);
       }
 
       validate();
 
       c.add(new JScrollPane(monEcran),BorderLayout.CENTER);
	   c.add(userList,BorderLayout.EAST);
	   c.add(userArea,BorderLayout.SOUTH);
Et voici là où je demande l'affichage dans le JTextPane :
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
 
 msg=msg+"                  ";//EVITER ARRAY EXCEPTION (SUBSTRING QUI RECHERCHERAIT TROP LOIN)
				   String textTemp="";
				   for(int cpt1 = 0; cpt1<msg.length();cpt1++)// Pour chaque lettre
				   {
					   int trouve=0;
					   if(msg.charAt(cpt1)=='#') // smiley possible
					   {
						   for(int cpt2=0 ; trouve==0 && cpt2<nomSmileys.length;cpt2++) // vérification de chaque smiely
						   {
							  if(msg.substring(cpt1+1,cpt1+nomSmileys[cpt2].length()+1).equals(nomSmileys[cpt2]))
							  {// SI UN SMILEY EST DETECTE
								  System.out.println("images\\"+nomSmileys[cpt2]+".jpg");
								  monSmil= new ImageIcon("images\\"+nomSmileys[cpt2]+".jpg");
								  if (monSmil != null) {
							            StyleConstants.setIcon(s, monSmil);
							        }
								  doc.insertString(doc.getLength(), "", doc.getStyle("icon"));
								  validate();
								  cpt1=cpt1+nomSmileys.length;
								  trouve=1;
							  }
 
						   }
					   }
					   if(trouve==0)
							  doc.insertString(doc.getLength(), ""+msg.charAt(cpt1), doc.getStyle("regular"));
				   }
 
			   }
 
 
		   }
	   }
Le texte s'affiche bien et je suis certain qu'il passe au bon endroit car il m'affiche le "System.out.println("images\\"+nomSmileys[cpt2]+".jpg"); "

Voila , merci d'avance !