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

AWT/Swing Java Discussion :

Erreur lors de l'utilisation de TableSorter.java


Sujet :

AWT/Swing Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé Avatar de Frac10
    Profil pro
    Inscrit en
    Avril 2006
    Messages
    81
    Détails du profil
    Informations personnelles :
    Âge : 44
    Localisation : France

    Informations forums :
    Inscription : Avril 2006
    Messages : 81
    Par défaut Erreur lors de l'utilisation de TableSorter.java
    Bonjour tout le monde !

    Alors voilà, j'utilise le TableSorter de Sun sur une JTable : cela marche convenablement lors de l'affichage initial du tableau mais lorsque je mets à jour ce tableau, j'ai une erreur sur le fichier TableSorter.java (et donc pas sur mon fichier perso) qui apparaît et la mise à jour du tableau se bloque. Par contre si je rafraîchi la fenêtre (en l'agrandissant par exemple), alors le tableau réapparait...

    Voilà cette erreur :
    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
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
            at TableSorter$Row.access$500(TableSorter.java:283)
            at TableSorter.modelIndex(TableSorter.java:237)
            at TableSorter.getValueAt(TableSorter.java:274)
            at javax.swing.JTable.getValueAt(Unknown Source)
            at javax.swing.JTable.prepareRenderer(Unknown Source)
            at javax.swing.plaf.basic.BasicTableUI.paintCell(Unknown Source)
            at javax.swing.plaf.basic.BasicTableUI.paintCells(Unknown Source)
            at javax.swing.plaf.basic.BasicTableUI.paint(Unknown Source)
            at javax.swing.plaf.ComponentUI.update(Unknown Source)
            at javax.swing.JComponent.paintComponent(Unknown Source)
            at javax.swing.JComponent.paint(Unknown Source)
            at javax.swing.JComponent.paintChildren(Unknown Source)
            at javax.swing.JComponent.paint(Unknown Source)
            at javax.swing.JViewport.paint(Unknown Source)
            at javax.swing.JComponent.paintChildren(Unknown Source)
            at javax.swing.JComponent.paint(Unknown Source)
            at javax.swing.JComponent.paintChildren(Unknown Source)
            at javax.swing.JComponent.paint(Unknown Source)
            at javax.swing.JComponent.paintWithOffscreenBuffer(Unknown Source)
            at javax.swing.JComponent.paintDoubleBuffered(Unknown Source)
            at javax.swing.JComponent._paintImmediately(Unknown Source)
            at javax.swing.JComponent.paintImmediately(Unknown Source)
            at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
            at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Source)
            at java.awt.event.InvocationEvent.dispatch(Unknown Source)
            at java.awt.EventQueue.dispatchEvent(Unknown Source)
            at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
            at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
            at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    Je n'arrive pas à comprendre d'où cela provient, donc si d'autres personnes ont déjà eu le même problème que moi lors de l'utilisation de ce TableSorter, çà serait sympa de m'éclairer...

  2. #2
    Membre confirmé
    Profil pro
    Inscrit en
    Septembre 2006
    Messages
    147
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Septembre 2006
    Messages : 147
    Par défaut
    J'ai aussi divers souci avec mon TableSorter. Les erreurs apparaissent directement à la première création du tableau.

    J'ai essayé de debugger, mais c'est vraiment galère. Apparemment, certain paramètres ne passent pas et on se retrouve a utiliser des valeurs nulles.

    Voici une partie de mes erreurs :

    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
     
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
            at utilisateursojv.TableSorter.getViewToModel(TableSorter.java:226)
            at utilisateursojv.TableSorter.modelIndex(TableSorter.java:237)
            at utilisateursojv.TableSorter.getValueAt(TableSorter.java:274)
            at javax.swing.JTable.getValueAt(JTable.java:1903)
            at javax.swing.JTable.prepareRenderer(JTable.java:3911)
            at javax.swing.plaf.basic.BasicTableUI.paintCell(BasicTableUI.java:2072)
            at javax.swing.plaf.basic.BasicTableUI.paintCells(BasicTableUI.java:1974)
            at javax.swing.plaf.basic.BasicTableUI.paint(BasicTableUI.java:1897)
            at javax.swing.plaf.ComponentUI.update(ComponentUI.java:142)
            at javax.swing.JComponent.paintComponent(JComponent.java:742)
            at javax.swing.JComponent.paint(JComponent.java:1005)
            at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4963)
            at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4916)
            at javax.swing.JComponent._paintImmediately(JComponent.java:4859)
            at javax.swing.JComponent.paintImmediately(JComponent.java:4666)
            at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:451)
            at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:114)
            at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
            at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
            at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
    Exception in thread "AWT-EventQueue-0" Exception in thread "AWT-EventQueue-0" Exception in thread "AWT-EventQueue-0" Exception in thread "AWT-EventQueue-0" Exception in thread "AWT-EventQueue-0""AWT-EventQueue-0" Exception in thread "AWT-EventQueue-0" Exception in thread "AWT-EventQueue-0" Exception in thread "AWT-EventQueue-0""AWT-EventQueue-0" Exception in thread "AWT-EventQueue-0" Exception in thread "AWT-EventQueue-0" Exception in thread "AWT-EventQueue-0" Exception in thread "AWT-EventQueue-0" Exception in thread "AWT-EventQueue-0" Exception in thread "AWT-EventQueue-0" Exception in thread "AWT-EventQueue-0" Exception in thread "AWT-EventQueue-0" Exception in thread "AWT-EventQueue-0" Exception in thread "AWT-EventQueue-0" Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
            at utilisateursojv.TableSorter.getViewToModel(TableSorter.java:226)
            at utilisateursojv.TableSorter.modelIndex(TableSorter.java:237)
            at utilisateursojv.TableSorter.getValueAt(TableSorter.java:274)
            at javax.swing.JTable.getValueAt(JTable.java:1903)
            at javax.swing.JTable.prepareRenderer(JTable.java:3911)
            at javax.swing.plaf.basic.BasicTableUI.paintCell(BasicTableUI.java:2072)
            at javax.swing.plaf.basic.BasicTableUI.paintCells(BasicTableUI.java:1974)
            at javax.swing.plaf.basic.BasicTableUI.paint(BasicTableUI.java:1897)
            at javax.swing.plaf.ComponentUI.update(ComponentUI.java:142)
            at javax.swing.JComponent.paintComponent(JComponent.java:742)
            at javax.swing.JComponent.paint(JComponent.java:1005)
            at javax.swing.JComponent.paintChildren(JComponent.java:842)
            at javax.swing.JComponent.paint(JComponent.java:1014)
            at javax.swing.JViewport.paint(JViewport.java:728)
            at javax.swing.JComponent.paintChildren(JComponent.java:842)
            at javax.swing.JComponent.paint(JComponent.java:1014)
            at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4963)
            at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4916)
            at javax.swing.JComponent._paintImmediately(JComponent.java:4859)
            at javax.swing.JComponent.paintImmediately(JComponent.java:4666)
            at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:451)
            at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:114)
            at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
            at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
            at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
    java.lang.NullPointerException
            at utilisateursojv.TableSorter.getViewToModel(TableSorter.java:226)
            at utilisateursojv.TableSorter.modelIndex(TableSorter.java:237)
            at utilisateursojv.TableSorter.getValueAt(TableSorter.java:274)
            at javax.swing.JTable.getValueAt(JTable.java:1903)
            at javax.swing.JTable.prepareRenderer(JTable.java:3911)
            at javax.swing.plaf.basic.BasicTableUI.paintCell(BasicTableUI.java:2072)

  3. #3
    Membre extrêmement actif Avatar de Satch
    Homme Profil pro
    Hypnothérapeute - Magicien
    Inscrit en
    Mars 2004
    Messages
    502
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : Suisse

    Informations professionnelles :
    Activité : Hypnothérapeute - Magicien

    Informations forums :
    Inscription : Mars 2004
    Messages : 502
    Par défaut
    Il y a plusieurs versions de ce TableSorter non ?

    Vous pouvez nous mettre un lien vers celui que vous utilisez qu'on y voit un peu plus clair ? (notamment pour les numéros de ligne)

  4. #4
    Membre confirmé Avatar de Frac10
    Profil pro
    Inscrit en
    Avril 2006
    Messages
    81
    Détails du profil
    Informations personnelles :
    Âge : 44
    Localisation : France

    Informations forums :
    Inscription : Avril 2006
    Messages : 81
    Par défaut
    Tout d'abord merci pour vos réponses.

    Pour Satch, voici un lien vers le fichier que j'utilise :

    TableSorter.java

    Voilà, çà à l'air de venir de cette ligne :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    return getViewToModel()[viewIndex].modelIndex;
    Mais je ne comprends toujours pas pourquoi...

  5. #5
    Membre extrêmement actif Avatar de Satch
    Homme Profil pro
    Hypnothérapeute - Magicien
    Inscrit en
    Mars 2004
    Messages
    502
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : Suisse

    Informations professionnelles :
    Activité : Hypnothérapeute - Magicien

    Informations forums :
    Inscription : Mars 2004
    Messages : 502
    Par défaut
    Bizarre.
    Je vais peut-être dire n'importe quoi, parce que je ne suis jamais tombé sur une stacktrace comme ça.

    Essaye (à tout hasard) de remplacer
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
        public int modelIndex(int viewIndex) {
            return getViewToModel()[viewIndex].modelIndex;
        }
    par
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
        public int modelIndex(int viewIndex) {
        	Row r = getViewToModel()[viewIndex];
        	if (r==null){
        		System.err.println("Evidemment que ça merde...");
        	}
            return r.modelIndex;
        }
    Si ça ne marque pas que ça merde, essaye (toujours à tout hasard mais j'y crois pas du tout) de remplacer le private modelIndex de la class Row par un protected.

  6. #6
    Membre confirmé
    Profil pro
    Inscrit en
    Septembre 2006
    Messages
    147
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Septembre 2006
    Messages : 147
    Par défaut
    J'ai la même version que Frac10, et j'ai la même erreur.

    J'ai essayé avec ton code, apparemment r n'est pas null, mais malgré ça il y a une erreur. J'ai exécuté mon code une bonne vingtaine de fois en pas à pas mais je n'y comprend rien.

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

Discussions similaires

  1. [POO] Erreur lors de l'utilisation de $this en PHP5
    Par Ekimasu dans le forum Langage
    Réponses: 4
    Dernier message: 03/11/2006, 21h21
  2. Erreur lors de l'utilisation de session_start();
    Par nane1474 dans le forum Langage
    Réponses: 8
    Dernier message: 30/06/2006, 13h06
  3. Erreur lors de l' utilisation des objets ADO
    Par aityahia dans le forum Bases de données
    Réponses: 10
    Dernier message: 24/03/2006, 14h46
  4. Eviter les erreurs lors de l'utilisation des compo Tsocket
    Par Coussati dans le forum Composants VCL
    Réponses: 5
    Dernier message: 01/02/2006, 20h14
  5. Erreur lors de l'utilisation de strlwr ?!
    Par MonsieurAk dans le forum C++
    Réponses: 4
    Dernier message: 05/12/2005, 11h22

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