Bonjour à tous,
J'utilise la version Java(TM) SE Runtime Environment (build 1.6.0_03-b05) et j'ai un problème avec un événement clavier. Dans un JTree j'ai la possibilité d'intervertir des noeuds en déplaçant un noeud vers le haut ou vers le bas. Je peux le faire par le biais d'un menu contextuel sur le noeud (ça fonctionne toujours) ou par un racourci clavier. Hors avec ce racourci clavier j'ai très souvent (mais pas toujours) l'exception suivante qui ne contient aucun point d'entrée dans mon code... d'où ma perplexité. Voici les éléments de code qui gèrent ce déplacement :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 jmitTreeMoveDown.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { CMTreeMenuControl.jmitMoveDownActionPerformed(e); } });Et voici l'exception. A noter qu'en mode debug elle n'est jamais apparue... alors qu'en mode normal elle arrive environ 8 fois sur 10...
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 public static synchronized void jmitMoveDownActionPerformed(KeyEvent e) { moveDown(); } public static synchronized void jmitMoveDownActionPerformed(ActionEvent e) { moveDown(); } private static void moveDown() { if(xmlTree.getLastSelectedPathComponent() != null) { chapterModel.move(xmlTree.getLastSelectedPathComponent(), "DOWN", xmlTree.getModel()); } }
Si vous avez des idées volontier. J'ai fait plusieurs recherche dans les forums sur le début de la trace et il y avait toujours un point d'entrée dans le code développé, là pas... Encore une chose, le déplacement du noeud dans l'arbre a quand même lieu...
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 Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at javax.swing.plaf.basic.BasicTreeUI$Handler.isNavigationKey(Unknown Source) at javax.swing.plaf.basic.BasicTreeUI$Handler.keyPressed(Unknown Source) at java.awt.AWTEventMulticaster.keyPressed(Unknown Source) at java.awt.Component.processKeyEvent(Unknown Source) at javax.swing.JComponent.processKeyEvent(Unknown Source) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source) at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source) at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Source) at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source) at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Window.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source)
merci
Partager