IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Agents de placement/Fenêtres Java Discussion :

[Exception]Lors d'un validate sur un jframe


Sujet :

Agents de placement/Fenêtres Java

  1. #1
    Membre habitué

    Profil pro
    Inscrit en
    Décembre 2002
    Messages
    120
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : Belgique

    Informations forums :
    Inscription : Décembre 2002
    Messages : 120
    Points : 133
    Points
    133
    Par défaut [Exception]Lors d'un validate sur un jframe
    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.

  2. #2
    Membre averti Avatar de piff62
    Inscrit en
    Décembre 2003
    Messages
    431
    Détails du profil
    Informations personnelles :
    Âge : 38

    Informations forums :
    Inscription : Décembre 2003
    Messages : 431
    Points : 417
    Points
    417
    Par défaut
    Montre nous exactement ton code qui te genere ton exception ?

  3. #3
    Membre habitué

    Profil pro
    Inscrit en
    Décembre 2002
    Messages
    120
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : Belgique

    Informations forums :
    Inscription : Décembre 2002
    Messages : 120
    Points : 133
    Points
    133
    Par défaut
    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();
      }
    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
    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)
    Voila l'exception ne refere aucune de mes classes, je sais juste que sa vient quand je mets le validate

  4. #4
    Membre à l'essai
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    17
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 17
    Points : 18
    Points
    18
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    setFont(new java.awt.Font("Arial", 0, 600));
    C'est pas une taille de police à 0 ?
    Je vois que ça de "bizarre".

  5. #5
    Membre habitué

    Profil pro
    Inscrit en
    Décembre 2002
    Messages
    120
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : Belgique

    Informations forums :
    Inscription : Décembre 2002
    Messages : 120
    Points : 133
    Points
    133
    Par défaut
    Non le 0 représente le style ... Ici pas de style.

  6. #6
    Membre régulier Avatar de jiraiya
    Inscrit en
    Mai 2002
    Messages
    100
    Détails du profil
    Informations forums :
    Inscription : Mai 2002
    Messages : 100
    Points : 116
    Points
    116
    Par défaut
    il ne faut pas mettre 0 mais Font.PLAIN

  7. #7
    Membre habitué

    Profil pro
    Inscrit en
    Décembre 2002
    Messages
    120
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : Belgique

    Informations forums :
    Inscription : Décembre 2002
    Messages : 120
    Points : 133
    Points
    133
    Par défaut
    Sa ne change rien. En plus je parie que la valeur de Font.PLAIN est 0...

  8. #8
    Membre à l'essai
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    17
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 17
    Points : 18
    Points
    18
    Par défaut
    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 ?

  9. #9
    Membre régulier Avatar de jiraiya
    Inscrit en
    Mai 2002
    Messages
    100
    Détails du profil
    Informations forums :
    Inscription : Mai 2002
    Messages : 100
    Points : 116
    Points
    116
    Par défaut
    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

  10. #10
    Membre habitué

    Profil pro
    Inscrit en
    Décembre 2002
    Messages
    120
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : Belgique

    Informations forums :
    Inscription : Décembre 2002
    Messages : 120
    Points : 133
    Points
    133
    Par défaut
    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 ...
    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()
          }
        }
      }
    }
    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
     
    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)
    Il n'y a aucune référence à mes classes

  11. #11
    Membre régulier Avatar de jiraiya
    Inscrit en
    Mai 2002
    Messages
    100
    Détails du profil
    Informations forums :
    Inscription : Mai 2002
    Messages : 100
    Points : 116
    Points
    116
    Par défaut
    peut être un léger problème avec le code html, essaye de l'afficher dans une page html normale

  12. #12
    Membre habitué

    Profil pro
    Inscrit en
    Décembre 2002
    Messages
    120
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : Belgique

    Informations forums :
    Inscription : Décembre 2002
    Messages : 120
    Points : 133
    Points
    133
    Par défaut
    Non sa ne change rien, j'ai meme enlever le document et tout ...

    Je te rermercie quand meme pour ton aide.

  13. #13
    Membre habitué

    Profil pro
    Inscrit en
    Décembre 2002
    Messages
    120
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : Belgique

    Informations forums :
    Inscription : Décembre 2002
    Messages : 120
    Points : 133
    Points
    133
    Par défaut
    C'était bien la taille de la police ... 600 est de trop

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. exception lors d'un update sur SQL serveur
    Par jeandadaf dans le forum VB.NET
    Réponses: 9
    Dernier message: 02/07/2009, 17h57
  2. Exception lors d'un clic sur une feuille d'un arbre
    Par gerudo dans le forum Langage
    Réponses: 4
    Dernier message: 24/04/2009, 09h59
  3. Réponses: 2
    Dernier message: 29/08/2008, 22h51
  4. [XSD] Exception lors d'une validation
    Par cash3000 dans le forum Format d'échange (XML, JSON...)
    Réponses: 3
    Dernier message: 08/06/2006, 09h17
  5. Réponses: 2
    Dernier message: 29/05/2006, 09h54

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo