bonjour,
j'ai un listener sur un jTree qui affiche une jTable, par ailleurs, j'ai un listener sur un jComboBox qui affiche une autre jTable.
en premier, une jTable est affichée par le listener du jComboBox, ensuite quand je clique sur les noeuds du jTree la deuxième jTable s'affiche mais à un certain moment en cliquant sur d'autre noeuds dans le jTree (sans que je clique sur les items du combobox) il y a le message d'erreur suivant qui s'affiche:
sachant que l'erreur 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 Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at outildediagnostic.expertise$14.getColumnClass(expertise.java:992) at javax.swing.JTable.getColumnClass(JTable.java:1833) at javax.swing.JTable.getCellRenderer(JTable.java:3878) at javax.swing.plaf.basic.BasicTableUI.paintCell(BasicTableUI.java:1984) at javax.swing.plaf.basic.BasicTableUI.paintCells(BasicTableUI.java:1887) at javax.swing.plaf.basic.BasicTableUI.paint(BasicTableUI.java:1810) 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)
pointe sur la ligne suivante
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 at outildediagnostic.expertise$14.getColumnClass(expertise.java:992)
du code suivant (le TableModel est celui de la jTable affichée par le listener du jTree):
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 public Class getColumnClass(int c) {return getValueAt(0, c).getClass();}
j'aimerais bien savoir d'où provient le problème.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 TableModel dataModel3 = new AbstractTableModel(){ public int getColumnCount() { return tab.length; } public int getRowCount() { return donnée.length;} public Object getValueAt(int row, int col) {return donnée[row][col];} public String getColumnName(int column) {return tab[column];} public Class getColumnClass(int c) {return getValueAt(0, c).getClass();} public boolean isCellEditable(int row, int col) {return col != 5;} public void setValueAt(Object aValue, int row, int column) { donnée[row] [column] = aValue; } };
merci.
Partager