Précédent   Forum du club des développeurs et IT Pro > Java > Interfaces Graphiques en Java > AWT/SWING
AWT/SWING
Forum d'entraide pour les API Swing et AWT. Avant de poster -> FAQ AWT/SWING
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse
 
Outils de la discussion
Publicité
'
Vieux 15/12/2012, 09h35   #1
karnass
Nouveau Membre du Club
 
Homme kikou
Développeur Java
Inscription : juillet 2012
Messages : 83
Détails du profil
Informations personnelles :
Nom : Homme kikou
Âge : 26
Localisation : Tunisie

Informations professionnelles :
Activité : Développeur Java
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : juillet 2012
Messages : 83
Points : 30
Points : 30
Envoyer un message via Skype™ à karnass
Par défaut Exception in thread

Lorsque je fait un clic sur le jtree , l'erreur suivant s'affiche malgré que mon application s’exécute à 100 % :
Code :
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
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
	at sd.expert.MenuPrincipale.jTree1MouseClicked(MenuPrincipale.java:1004)
	at sd.expert.MenuPrincipale.access$400(MenuPrincipale.java:22)
	at sd.expert.MenuPrincipale$5.mouseClicked(MenuPrincipale.java:229)
	at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:270)
	at java.awt.Component.processMouseEvent(Component.java:6507)
	at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
	at java.awt.Component.processEvent(Component.java:6269)
	at java.awt.Container.processEvent(Container.java:2229)
	at java.awt.Component.dispatchEventImpl(Component.java:4860)
	at java.awt.Container.dispatchEventImpl(Container.java:2287)
	at java.awt.Component.dispatchEvent(Component.java:4686)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4501)
	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
	at java.awt.Container.dispatchEventImpl(Container.java:2273)
	at java.awt.Window.dispatchEventImpl(Window.java:2713)
	at java.awt.Component.dispatchEvent(Component.java:4686)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:707)
	at java.awt.EventQueue.access$000(EventQueue.java:101)
	at java.awt.EventQueue$3.run(EventQueue.java:666)
	at java.awt.EventQueue$3.run(EventQueue.java:664)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
	at java.awt.EventQueue$4.run(EventQueue.java:680)
	at java.awt.EventQueue$4.run(EventQueue.java:678)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:677)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
voila le code de mon Jtree
Code :
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
 try { //Affichage jtree dans un nouveau onglet
String nom_noeud = jTree1.getLastSelectedPathComponent().toString();
 
if (evt.getClickCount()==2)
        {
 
            if ( nom_noeud .equals("Utilisateur"))// si le noeud de jtree est utilisateur 
            {
                jTabbedPane1.addTab(nom_noeud ,Panel_New_User); 
 
// remplissage de tableau des users dans le table user de jpanel new user
                int k = Table_User.getColumnCount();
                int l = Table_User.getRowCount();
                Conexion1 A = new Conexion1();
                //DefaultTableModel aModel = (DefaultTableModel) Table_User.getModel();
                 DefaultTableModel aModel = new DefaultTableModel (l,k){
    public boolean isCellEditable(int iRowIndex, int iColumnIndex)
    {
          return false;
 
    }
  };  
                aModel.getDataVector().removeAllElements();  // pour vider la table et eliminer la redondance d'affichage
 
                    ResultSet ResultUser =      A.Conn().executeQuery("select * from users");
                    ResultSetMetaData rsmd = ResultUser.getMetaData();
                    int cols = rsmd.getColumnCount();
                    while (ResultUser.next())
 
                    {
                        Object[] row = new Object[cols];
                        for (int j = 0; j < row.length; j++) {
                            row[j] = ResultUser.getObject(j + 1);
 
                        }
                        aModel.addRow(row);
                    }
 
                    Table_User.setModel(aModel);
                    jTable1.setModel(aModel);
                    Table_User.repaint();
                     }
 
            }
                    // TODO add your handling code here:
                } catch (SQLException | RemoteException ex) {
                    Logger.getLogger(MenuPrincipale.class.getName()).log(Level.SEVERE, null, ex);
 
 
        }
j'ai fait un recherche sur internet mais j'ai rien trouvé concernant cette erreur
karnass est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 15/12/2012, 18h35   #2
sinok
Modérateur
 
Avatar de sinok
 
Inscription : août 2004
Messages : 8 661
Détails du profil
Informations personnelles :
Âge : 33
Localisation : France, Paris (Île de France)

Informations forums :
Inscription : août 2004
Messages : 8 661
Points : 12 475
Points : 12 475
Quelle est la ligne de code correspondant à
at sd.expert.MenuPrincipale.jTree1MouseClicked(MenuPrincipale.java:1004)
__________________
Hey, this is mine. That's mine. All this is mine. I'm claiming all this as mine. Except that bit. I don't want that bit. But all the rest of this is mine. Hey, this has been a really good day. I've eaten five times, I've slept six times, and I've made a lot of things mine. Tomorrow, I'm gonna see if I can't have sex with something.
sinok est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 15/12/2012, 18h43   #3
karnass
Nouveau Membre du Club
 
Homme kikou
Développeur Java
Inscription : juillet 2012
Messages : 83
Détails du profil
Informations personnelles :
Nom : Homme kikou
Âge : 26
Localisation : Tunisie

Informations professionnelles :
Activité : Développeur Java
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : juillet 2012
Messages : 83
Points : 30
Points : 30
Envoyer un message via Skype™ à karnass
Code :
String nom_noeud = jTree1.getLastSelectedPathComponent().toString();
karnass est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 16/12/2012, 11h51   #4
tchize_
Expert Confirmé Sénior
 
Avatar de tchize_
 
Homme
Responsable de service informatique
Inscription : avril 2007
Messages : 18 412
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 33
Localisation : Belgique

Informations professionnelles :
Activité : Responsable de service informatique
Secteur : Service public

Informations forums :
Inscription : avril 2007
Messages : 18 412
Points : 33 154
Points : 33 154
Envoyer un message via MSN à tchize_ Envoyer un message via Skype™ à tchize_
Tu dois traiter le cas où getLastSelectedPathComponent() te retourne null. Il n'y a pas nécessairement d'élément sélectionné dans le JTree au moment du clicked.
Si tu a cliqué ailleurs que sur un élément ou si ton listener se déclenche avant le listenr gérant la sélection dans JTree.

Si tu veux être notifié des éléments sélectionné, il y a des listener Spécifiques pour ça dans Jtree (TreeSelectionListener)
__________________
⥀⥁ Чиз faq java, cours java, javadoc. Pensez à et
Laisse entrer le jour après une nuit sombre. Si tu es toujours là, tu n'es pas faite pour mourir.
tchize_ est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 17/12/2012, 09h27   #5
karnass
Nouveau Membre du Club
 
Homme kikou
Développeur Java
Inscription : juillet 2012
Messages : 83
Détails du profil
Informations personnelles :
Nom : Homme kikou
Âge : 26
Localisation : Tunisie

Informations professionnelles :
Activité : Développeur Java
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : juillet 2012
Messages : 83
Points : 30
Points : 30
Envoyer un message via Skype™ à karnass
La même erreur existe toujours même après le traitement de cas null
karnass est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse
Outils de la discussion

Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 23h46.


 
 
 
 
Partenaires

Hébergement Web