Voila lorsque je lance la commande validate, j'obtient l'exception suivant :
java.lang.IllegalArgumentException: Zero length string passed to TextLayout constructor.
Est ce que qq'un sait a quoi cela est du car là je sèche.
Voila lorsque je lance la commande validate, j'obtient l'exception suivant :
java.lang.IllegalArgumentException: Zero length string passed to TextLayout constructor.
Est ce que qq'un sait a quoi cela est du car là je sèche.
Montre nous exactement ton code qui te genere ton exception ?
Exception :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 public void setOuvert(boolean ouvert){ this.ouvert=ouvert; if(ouvert){ jLabel1.setFont(new java.awt.Font("Arial", 0, 600)); this.getContentPane().setBackground(new Color(0, 0, 76)); this.getContentPane().remove(jep); this.getContentPane().add(jLabel1, BorderLayout.CENTER); }else{ this.getContentPane().remove(jLabel1); this.getContentPane().add(jep, BorderLayout.CENTER); } this.validate(); }
Voila l'exception ne refere aucune de mes classes, je sais juste que sa vient quand je mets le validate
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 java.lang.IllegalArgumentException: Zero length string passed to TextLayout constructor. at java.awt.font.TextLayout.<init>(TextLayout.java:471) at sun.java2d.pipe.OutlineTextRenderer.drawString(OutlineTextRenderer.java:67) at sun.java2d.pipe.GlyphListPipe.drawString(GlyphListPipe.java:32) at sun.java2d.pipe.ValidatePipe.drawString(ValidatePipe.java:123) at sun.java2d.SunGraphics2D.drawString(SunGraphics2D.java:2534) at javax.swing.plaf.basic.BasicGraphicsUtils.drawStringUnderlineCharAt(BasicGraphicsUtils.java:234) at javax.swing.plaf.basic.BasicLabelUI.paintEnabledText(BasicLabelUI.java:81) at javax.swing.plaf.basic.BasicLabelUI.paint(BasicLabelUI.java:164) at javax.swing.plaf.ComponentUI.update(ComponentUI.java:142) at javax.swing.JComponent.paintComponent(JComponent.java:541) at javax.swing.JComponent.paint(JComponent.java:808) at javax.swing.JComponent.paintChildren(JComponent.java:647) at javax.swing.JComponent.paint(JComponent.java:817) at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4795) at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4748) at javax.swing.JComponent._paintImmediately(JComponent.java:4692) at javax.swing.JComponent.paintImmediately(JComponent.java:4495) at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:410) at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:117) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178) at java.awt.EventQueue.dispatchEvent(EventQueue.java:454) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137) at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
C'est pas une taille de police à 0 ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part setFont(new java.awt.Font("Arial", 0, 600));
Je vois que ça de "bizarre".
Non le 0 représente le style ... Ici pas de style.
Sa ne change rien. En plus je parie que la valeur de Font.PLAIN est 0...
Ca change rien à ton problème, mais ça change la vie à celui qui lit ton code. S'il a été créé une constante, c'est bien pour que ça soit plus lisible que 0.
Tout ça pour dire que, oui, la valeur de Font.PLAIN est peut-être 0, mais la remarque de jiraiya est loin d'être anodine.
Aprés avoir jeté un oeil au constructeur, tu veux donc une taille de police de 600 ??
PS : la ligne qui lève l'exception, c'est laquelle exactement ?
et 600 en taille de police ça fait pas un peut grand, sinon ça peut venir de la police Arial qu'il ne trouve pas, essaye de lister toutes les polices disponibles sur le système avec la fonction getAllFonts de la classe GraphicsEnvironment
Ok pour le Font.PLAIN, en fait c'est mon ide qui marque sa ...
Concernant les font, je les ai lister, et il n'y a aucun problème, Arial s'y trouve.
Voici la classe entière qui doit encore etre refactorer ...
L'exception lancée est la suivante :
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 package fileattente; import javax.swing.*; import java.awt.*; import java.util.Properties; import javax.swing.text.html.*; /** * <p>Title: File d'attente</p> * <p>Description: Gestion des files d'attentes</p> * <p>Copyright: Copyright (c) 2005</p> * <p>Company: Commune de Jette</p> * @author Frédéric Pirson- * @version 1.0 */ public class GuichetGui extends JWindow implements Runnable{ BorderLayout borderLayout1 = new BorderLayout(); int compteur=0; JLabel jLabel1 = new JLabel(); boolean ouvert = false; Dimension screenSize = screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Thread thread; Properties properties; JEditorPane jep = new JEditorPane(); HTMLEditorKit m_htmlEK = new HTMLEditorKit(); HTMLDocument m_htmlDoc = null; public GuichetGui(Properties p) { properties = p; thread = new Thread(this); //thread.start(); try { jbInit(); } catch(Exception ex) { ex.printStackTrace(); } } public Dimension getDimension(){ return this.screenSize; } void jbInit() throws Exception { this.getContentPane().setBackground(new Color(145, 0, 0)); jLabel1.setForeground(Color.white); jLabel1.setHorizontalAlignment(SwingConstants.CENTER); jLabel1.setHorizontalTextPosition(SwingConstants.CENTER); m_htmlEK.setDefaultCursor(new Cursor(Cursor.TEXT_CURSOR)); m_htmlDoc = (HTMLDocument)(m_htmlEK.createDefaultDocument()); jep.setEditorKit(m_htmlEK); jep.setDocument(m_htmlDoc); jep.setText("<HTML><HEAD></HEAD><BODY bgcolor=\"#910000\"><TABLE WIDTH=\"1280\" HEIGHT=\"1024\" BORDER=\"0\" BGCOLOR=\"#910000\" bordercolor=\"#910000\">"+ "<TR> <TD ALIGN=\"CENTER\" VALIGN=\"MIDDLE\">"+ "<P><BR><BR><BR><BR><BR><BR><BR><FONT style=\"font-size:200pt\" COLOR=\"#FFFFFF\" FACE=\"Arial, Helvetica, sans-serif\">FERMÉ</FONT></P><P><FONT style=\"font-size:200pt\" COLOR=\"#FFFFFF\" FACE=\"Arial, Helvetica, sans-serif\">-</font></P><P><FONT style=\"font-size:200pt\" COLOR=\"#FFFFFF\" FACE=\"Arial, Helvetica, sans-serif\">GESLOTEN</FONT><BR><BR><BR><BR><BR><BR><BR></P></TD>"+ "</TR></TABLE></BODY></HTML>"); this.setForeground(Color.black); this.getContentPane().setLayout(borderLayout1); if(ouvert)this.getContentPane().add(jLabel1, BorderLayout.CENTER); else this.getContentPane().add(jep, BorderLayout.CENTER); } public void setCompteur(int compteur){ this.compteur=compteur; this.jLabel1.setText(""+compteur); } public void setOuvert(boolean ouvert){ this.ouvert=ouvert; if(ouvert){ jLabel1.setFont(new java.awt.Font("Arial", Font.PLAIN, 600)); this.getContentPane().setBackground(new Color(0, 0, 76)); this.getContentPane().remove(jep); this.getContentPane().add(jLabel1, BorderLayout.CENTER); }else{ this.getContentPane().remove(jLabel1); this.getContentPane().add(jep, BorderLayout.CENTER); } this.validate(); } public int getCompteur(){ return compteur; } /** * run * @todo Implementing */ public void run() { while(thread != null){ if(!ouvert){ //sleep() } } } }
Il n'y a aucune référence à mes classes
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 java.lang.IllegalArgumentException: Zero length string passed to TextLayout constructor. at java.awt.font.TextLayout.<init>(TextLayout.java:471) at sun.java2d.pipe.OutlineTextRenderer.drawString(OutlineTextRenderer.java:67) at sun.java2d.pipe.GlyphListPipe.drawString(GlyphListPipe.java:32) at sun.java2d.pipe.ValidatePipe.drawString(ValidatePipe.java:123) at sun.java2d.SunGraphics2D.drawString(SunGraphics2D.java:2534) at javax.swing.plaf.basic.BasicGraphicsUtils.drawStringUnderlineCharAt(BasicGraphicsUtils.java:234) 1115022718631 at javax.swing.plaf.basic.BasicLabelUI.paintEnabledText(BasicLabelUI.java:81) at javax.swing.plaf.basic.BasicLabelUI.paint(BasicLabelUI.java:164) at javax.swing.plaf.ComponentUI.update(ComponentUI.java:142) at javax.swing.JComponent.paintComponent(JComponent.java:541) at javax.swing.JComponent.paint(JComponent.java:808) at javax.swing.JComponent.paintChildren(JComponent.java:647) at javax.swing.JComponent.paint(JComponent.java:817) at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4795) at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4748) at javax.swing.JComponent._paintImmediately(JComponent.java:4692) at javax.swing.JComponent.paintImmediately(JComponent.java:4495) at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:410) at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:117) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178) at java.awt.EventQueue.dispatchEvent(EventQueue.java:454) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137) at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
peut être un léger problème avec le code html, essaye de l'afficher dans une page html normale
Non sa ne change rien, j'ai meme enlever le document et tout ...
Je te rermercie quand meme pour ton aide.
C'était bien la taille de la police ... 600 est de trop
Vous avez un bloqueur de publicités installé.
Le Club Developpez.com n'affiche que des publicités IT, discrètes et non intrusives.
Afin que nous puissions continuer à vous fournir gratuitement du contenu de qualité, merci de nous soutenir en désactivant votre bloqueur de publicités sur Developpez.com.
Partager