Bonjour,
j'essaye d'afficher une Jtable dans une interface graphique.
j'utilise:

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
 
   JFrame frame = new JFrame();
    ImageIcon Applicon = new ImageIcon(jar.getResource("icons/iconAppli.gif"));
    frame.setIconImage(Applicon.getImage());
 
   JDialog dialog = new JDialog(frame);
 
   dialog.setContentPane(getPrivateCleaningTable());
   dialog.pack();
 
   Toolkit tk = Toolkit.getDefaultToolkit();
   Dimension screenSize = tk.getScreenSize();
 
    dialog.setBounds(screenSize.width*5/100,screenSize.height*5/100,screenSize.width*90/100,screenSize.height*90/100);// center
 
   dialog.setTitle(this.getFullApplicationName()+" (secondary)");  
   dialog.show();
qui renvoie à :

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
JTable cleanTable = new JTable(DCMParser.getPrivateCleanList(), DCMParser.getPrivateColumnNames());// get Table data Object
 
 
   javax.swing.table.DefaultTableCellRenderer dtcr = new javax.swing.table.DefaultTableCellRenderer();
   dtcr.setHorizontalAlignment(SwingConstants.CENTER);
 
   for(int x=0;x<cleanTable.getColumnModel().getColumnCount();x++)// center all excepted 1
               if(x!=1)cleanTable.getColumnModel().getColumn(x).setCellRenderer(dtcr);
 
    cleanTable.getColumnModel().getColumn(1).setPreferredWidth(250);
 
    cleanTable.setGridColor(new Color(220,220,225));
 
    TableCellRenderer rendererFromHeader = cleanTable.getTableHeader().getDefaultRenderer();
    JLabel headerLabel = (JLabel)rendererFromHeader;
    headerLabel.setHorizontalAlignment(JLabel.CENTER);
    cleanTable.getTableHeader().setFont(new Font("Tahoma", Font.BOLD, 11));
et à chaque tentative d'affichage, j'obtiens un message d'erreur du type:
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
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 0
	at javax.swing.JTable$1.getValueAt(Unknown Source)
	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.JSplitPane.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.paintChildren(Unknown Source)
	at javax.swing.JComponent.paint(Unknown Source)
	at javax.swing.JComponent.paintToOffscreen(Unknown Source)
	at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(Unknown Source)
	at javax.swing.RepaintManager$PaintManager.paint(Unknown Source)
	at javax.swing.RepaintManager.paint(Unknown Source)
	at javax.swing.JComponent._paintImmediately(Unknown Source)
	at javax.swing.JComponent.paintImmediately(Unknown Source)
	at javax.swing.RepaintManager$3.run(Unknown Source)
	at javax.swing.RepaintManager$3.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
	at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
	at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
	at javax.swing.RepaintManager.prePaintDirtyRegions(Unknown Source)
	at javax.swing.RepaintManager.access$1100(Unknown Source)
	at javax.swing.RepaintManager$ProcessingRunnable.run(Unknown Source)
	at java.awt.event.InvocationEvent.dispatch(Unknown Source)
	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
	at java.awt.EventQueue.access$200(Unknown Source)
	at java.awt.EventQueue$3.run(Unknown Source)
	at java.awt.EventQueue$3.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(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)
(le indexoutofbounds varie parfois).

J'ai changé le tableau manuellement par quelque chose de très simple
(A B C D E en titre, et 1 2 3 4 5 sur chaque ligne...) pour être sur que l'erreur ne venait pas de mon tableau, et j'ai toujours la même erreur...
quelqu'un aurait une idée pour m'aider?
merci d'avance!