Bonjour,

Dans mon applet, je souhaite empiler plusieurs images (le nombre est inconnu), je me demande ce qui est le mieux en terme de performance / qualité :

Solution 1 :
Utiliser un champ JTextPane :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
 
JTextPane test = new JTextPane();
test.setContentType( "text/html" );
test.setEditable(false);
add(test);
test.setText("<html><div style='Font-weight: bold;Text-align: center;width: 100px;position: absolute; left: 630px; top: 190px;'><img src='jar:http://192.168.1.3/applet.jar!/files/img/chips/1.png' alt='1' style='position:absolute;left:0px;top:10px;width:22px;height:17px;'/><img src='jar:http://192.168.1.3/applet.jar!/files/img/chips/1.png' alt='1' style='position:absolute;left:0px;top:8px;width:22px;height:17px;'/><img src='jar:http://192.168.1.3/applet.jar!/files/img/chips/1.png' alt='1' style='position:absolute;left:0px;top:6px;width:22px;height:17px;'/><img src='jar:http://192.168.1.3/applet.jar!/files/img/chips/1.png' alt='1' style='position:absolute;left:0px;top:4px;width:22px;height:17px;'/><img src='jar:http://192.168.1.3/applet.jar!/files/img/chips/5.png' alt='5' style='position:absolute;left:0px;top:2px;width:22px;height:17px;'/><img src='jar:http://192.168.1.3/applet.jar!/files/img/chips/5.png' alt='5' style='position:absolute;left:0px;top:0px;width:22px;height:17px;'/><img src='jar:http://192.168.1.3/applet.jar!/files/img/chips/25.png' alt='25' style='position:absolute;left:0px;top:-2px;width:22px;height:17px;'/><img src='jar:http://192.168.1.3/applet.jar!/files/img/chips/25.png' alt='25' style='position:absolute;left:0px;top:-4px;width:22px;height:17px;'/><img src='jar:http://192.168.1.3/applet.jar!/files/img/chips/25.png' alt='25' style='position:absolute;left:0px;top:-6px;width:22px;height:17px;'/><img src='jar:http://192.168.1.3/applet.jar!/files/img/chips/100.png' alt='100' style='position:absolute;left:0px;top:-8px;width:22px;height:17px;'/><img src='jar:http://192.168.1.3/applet.jar!/files/img/chips/100.png' alt='100' style='position:absolute;left:0px;top:-10px;width:22px;height:17px;'/></div></html>");
Problème : Le CSS est mal géré -> voir les API jdic ou xhtmlrenderer ?

Solution 2 :
Manipuler les image pour les empiler via des copier-coller puis insertion dans un Jlabel.

Vous en pensez quoi ?

Edit : J'ai essayé xhtmlrenderer avec :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
XHTMLPanel test42 = new XHTMLPanel();
String StringXhtml = "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'DTD/xhtml1-strict.dtd'><html xmlns='http://www.w3.org/1999/xhtml' xml:lang='fr' lang='fr'><head><title>Exemple XHTML 1.0</title></head><body><div style='Font-weight: bold;Text-align: center;width: 100px;position: absolute; left: 630px; top: 190px;'> <img src='jar:http://192.168.1.3/getflush/applet.jar!/files/img/chips/1.png' alt='1' style='position:absolute;left:0px;top:10px;width:22px;height:17px;' /> <img src='jar:http://192.168.1.3/getflush/applet.jar!/files/img/chips/1.png' alt='1' style='position:absolute;left:0px;top:8px;width:22px;height:17px;' /> <img src='jar:http://192.168.1.3/getflush/applet.jar!/files/img/chips/1.png' alt='1' style='position:absolute;left:0px;top:6px;width:22px;height:17px;' /> <img src='jar:http://192.168.1.3/getflush/applet.jar!/files/img/chips/1.png' alt='1' style='position:absolute;left:0px;top:4px;width:22px;height:17px;' /><img src='jar:http://192.168.1.3/getflush/applet.jar!/files/img/chips/5.png' alt='5' style='position:absolute;left:0px;top:2px;width:22px;height:17px;' /> <img src='jar:http://192.168.1.3/getflush/applet.jar!/files/img/chips/5.png' alt='5' style='position:absolute;left:0px;top:0px;width:22px;height:17px;' /> <img src='jar:http://192.168.1.3/getflush/applet.jar!/files/img/chips/25.png' alt='25' style='position:absolute;left:0px;top:-2px;width:22px;height:17px;' /> <img src='jar:http://192.168.1.3/getflush/applet.jar!/files/img/chips/25.png' alt='25' style='position:absolute;left:0px;top:-4px;width:22px;height:17px;' /> <img src='jar:http://192.168.1.3/getflush/applet.jar!/files/img/chips/25.png' alt='25' style='position:absolute;left:0px;top:-6px;width:22px;height:17px;' /> <img src='jar:http://192.168.1.3/getflush/applet.jar!/files/img/chips/100.png' alt='100' style='position:absolute;left:0px;top:-8px;width:22px;height:17px;' /><img src='jar:http://192.168.1.3/getflush/applet.jar!/files/img/chips/100.png' alt='100' style='position:absolute;left:0px;top:-10px;width:22px;height:17px;' /></div></body></html>";
test42.setDocumentFromString(StringXhtml, null, new XhtmlNamespaceHandler() );
Et ça résout pas mon problème de mise en forme