l'erreur c'est donc :
java.lang.NullPointerException
at RendererJT_PhasesFinales.getTableCellRendererComponent(RendererJT_PhasesFinales.java:34)
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.JLayeredPane.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paintWithOffscreenBuffer(Unknown Source)
at javax.swing.JComponent.paintDoubleBuffered(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at java.awt.GraphicsCallback$PaintCallback.run(Unknown Source)
at sun.awt.SunGraphicsCallback.runOneComponent(Unknown Source)
at sun.awt.SunGraphicsCallback.runComponents(Unknown Source)
at java.awt.Container.paint(Unknown Source)
at sun.awt.RepaintArea.paint(Unknown Source)
at sun.awt.windows.WComponentPeer.handleEvent(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.pumpOneEventForHierarchy(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 code c'est :
import javax.swing.table.*;
import java.awt.*;
import javax.swing.* ;
import javax.swing.border.*;
/*
* Créé le 24 juin 2004
*
*/
/**
* @author guillaume
*
*/
public class RendererJT_PhasesFinales extends DefaultTableCellRenderer {
public Component getTableCellRendererComponent( JTable table,Object value,boolean isSelected,
boolean hasFocus,int row,int column){
Component cell = super.getTableCellRendererComponent(table, value,isSelected, hasFocus, row, column);
Border raisedbevel = BorderFactory.createRaisedBevelBorder();
if ( ((column==0)&&(row%2==0)) ) {
cell.setBackground(Color.red);
cell.setForeground(Color.white);
//setBorder(raisedbevel) ;
// setBorder(BorderFactory.createLoweredBevelBorder()) ;
}
else if ((column>0)&&(row>0)&&( (Math.power(2,column)-1) == row % (Math.power(2,column+1)) ) ) {
cell.setBackground(Color.red);
cell.setForeground(Color.white);
}
else if (table.getModel().getValueAt(row,column).equals("Match" )) {
cell.setBackground(Color.green) ;
}
else {
cell.setBackground(Color.black);
cell.setForeground(Color.black);
}
setHorizontalAlignment( CENTER );
return cell ;
}
}