Problemas no jTable

Qual é o motivo do erro abaixo na chamada ?changeSelection? de um jTable?

Exception in thread “Alternador de Planta” java.lang.ClassCastException: sun.java2d.NullSurfaceData cannot be cast to sun.java2d.d3d.D3DSurfaceData
at sun.java2d.d3d.D3DRenderer.copyArea(D3DRenderer.java:55)
at sun.java2d.d3d.D3DSurfaceData.copyArea(D3DSurfaceData.java:641)
at sun.java2d.SunGraphics2D.doCopyArea(SunGraphics2D.java:1986)
at sun.java2d.SunGraphics2D.copyArea(SunGraphics2D.java:1968)
at javax.swing.BufferStrategyPaintManager.copyArea(BufferStrategyPaintManager.java:315)
at javax.swing.RepaintManager.copyArea(RepaintManager.java:1232)
at javax.swing.JViewport.blitDoubleBuffered(JViewport.java:1604)
at javax.swing.JViewport.windowBlitPaint(JViewport.java:1573)
at javax.swing.JViewport.setViewPosition(JViewport.java:1118)
at javax.swing.JViewport.scrollRectToVisible(JViewport.java:415)
at javax.swing.JComponent.scrollRectToVisible(JComponent.java:3063)
at javax.swing.JTable.changeSelection(JTable.java:2429)

Olá…

sem o código fica difícil…
Porem o erro é claro =]

[]'s

Foda esse erro hein. Procurando no google não encontrei muita informação, mas esse achei sensacional
http://dragonscape.nstars.org/bugs-f25/how-can-i-solve-this-t14766.htm

Olha o q o superkootje acha q é! :smiley:

[quote=marcosvidolin]Olá…

sem o código fica difícil…
Porem o erro é claro =]

[]'s[/quote]
Caro Marcos,

Como você havia comentando estou lhe enviando o código fonte completo onde ocorre o problema. E importante ressaltar que este código fonte está acelerado para que o erro ocorra com maior facilidade, mas mesmo assim aqui em minha maquina ele foi ocorre depois de uns 45 minutos de execução. Alem do erro principal, você vai notar que em alguns momentos da execução do programa partes da jTable será impressa em regiões da janela que não deveria ser impressa.

[code]/*

  • To change this template, choose Tools | Templates
  • and open the template in the editor.
    */

/*

  • Test.java
  • Created on 15/04/2010, 08:08:17
    */

package javaapplication17;

import java.awt.Color;
import java.awt.Component;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultListSelectionModel;

import javax.swing.JPanel;

/**
*

  • @author siaplus
    */
    public class Test extends javax.swing.JFrame {

    /** Creates new form Test /
    public Test() {
    initComponents();
    jTable1.setSelectionMode(DefaultListSelectionModel.SINGLE_SELECTION);
    for(int cont=0;cont<jTable1.getRowCount();cont++){
    JPanel jPanel=new JPanel();
    jPanel.setVisible(false);
    Color color=new Color(((cont
    10)&0xFF),((contcont)&0xFF),((contcont*cont)&0xFF));
    jPanel.setBackground(color);
    jPanel.setSize(jPanel1.getWidth()-20,jPanel1.getHeight()-30);
    jPanel.setLocation(10,20);
    jPanel1.add(jPanel);
    }
    }
    public void InicializaAlternaciaDeSelecao(){
    new Thread(){
    @Override
    public void run() {
    int posicao=0;
    int posicaoAnterior=0;
    super.run();
    this.setName(“Alternador de selecão”);
    while(true){
    synchronized(jTable1.getTreeLock()){
    Component component=jPanel1.getComponent(posicaoAnterior);
    if(component instanceof JPanel){
    component.setVisible(false);
    }
    component=jPanel1.getComponent(posicao);
    if(component instanceof JPanel){
    component.setVisible(true);
    }
    jTable1.changeSelection(posicao,-1,false,false);
    posicaoAnterior=posicao;
    posicao++;
    if(posicao>=jTable1.getRowCount()){
    posicao=0;
    }

         }		
         try {
     	Thread.sleep(50);
         } catch (InterruptedException ex) {
     	Logger.getLogger(Test.class.getName()).log(Level.SEVERE, null, ex);
         }
     }
     }
    

    }.start();
    }
    public void InicializaStatus1(){
    new Thread(){

     @Override
     public void run() {
     int posicao=0;
     super.run();
     this.setName("Status 1");
     while(true){
         synchronized(jTable1.getTreeLock()){
     	if(jTable1.getValueAt(posicao,1).equals("OK")){
     	    jTable1.setValueAt("ERRO",posicao,1);
     	}else{
     	    jTable1.setValueAt("OK",posicao,1);
     	}
     	posicao++;
     	if(posicao>=jTable1.getRowCount()){
     	    posicao=0;
     	    try {
     		Thread.sleep(25);
     	    } catch (InterruptedException ex) {
     		Logger.getLogger(Test.class.getName()).log(Level.SEVERE, null, ex);
     	    }
     	}			
         }
         try {
     	Thread.sleep(1);
         } catch (InterruptedException ex) {
     	Logger.getLogger(Test.class.getName()).log(Level.SEVERE, null, ex);
         }
        
     }
     }
    

    }.start();
    }
    public void InicializaStatus2(){
    new Thread(){

     @Override
     public void run() {
     int posicao=0;
     super.run();
     this.setName("Status 2");
     while(true){
         synchronized(jTable1.getTreeLock()){
     	int valor=Integer.parseInt((String)jTable1.getValueAt(posicao,2))+1;
     	if(valor>1024){
     	    valor=0;
     	}
     	jTable1.setValueAt(""+valor,posicao,2);
     	posicao++;
     	if(posicao>=jTable1.getRowCount()){
     	    posicao=0;
     	    try {
     		Thread.sleep(25);
     	    } catch (InterruptedException ex) {
     		Logger.getLogger(Test.class.getName()).log(Level.SEVERE, null, ex);
     	    }
     	}			
         }
         try {
     	Thread.sleep(1);
         } catch (InterruptedException ex) {
     	Logger.getLogger(Test.class.getName()).log(Level.SEVERE, null, ex);
         }
     }
     }
    

    }.start();
    }
    /** This method is called from within the constructor to

    • initialize the form.

    • WARNING: Do NOT modify this code. The content of this method is

    • always regenerated by the Form Editor.
      */
      @SuppressWarnings(“unchecked”)
      //
      private void initComponents() {

      jScrollPane1 = new javax.swing.JScrollPane();
      jTable1 = new javax.swing.JTable();
      jPanel1 = new javax.swing.JPanel();

      setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

      jTable1.setModel(new javax.swing.table.DefaultTableModel(
      new Object [][] {
      {“Nome 1”, “OK”, “1”},
      {“Nome 2”, “OK”, “2”},
      {“Nome 3”, “OK”, “3”},
      {“Nome 4”, “OK”, “4”},
      {“Nome 5”, “OK”, “5”},
      {“Nome 6”, “OK”, “6”},
      {“Nome 7”, “OK”, “7”},
      {“Nome 8”, “OK”, “8”},
      {“Nome 9”, “OK”, “9”},
      {“Nome 10”, “OK”, “10”},
      {“Nome 11”, “OK”, “11”},
      {“Nome 12”, “OK”, “12”},
      {“Nome 13”, “OK”, “13”},
      {“Nome 14”, “OK”, “14”},
      {“Nome 15”, “OK”, “15”},
      {“Nome 16”, “OK”, “16”},
      {“Nome 17”, “OK”, “17”},
      {“Nome 18”, “OK”, “18”},
      {“Nome 19”, “OK”, “19”},
      {“Nome 20”, “OK”, “20”},
      {“Nome 21”, “OK”, “21”},
      {“Nome 22”, “OK”, “22”},
      {“Nome 23”, “OK”, “23”},
      {“Nome 24”, “OK”, “24”},
      {“Nome 25”, “OK”, “25”},
      {“Nome 26”, “OK”, “26”}
      },
      new String [] {
      “Nome”, “Status 1”, “Status 2”
      }
      ) {
      Class[] types = new Class [] {
      java.lang.String.class, java.lang.String.class, java.lang.String.class
      };

       public Class getColumnClass(int columnIndex) {
           return types [columnIndex];
       }
      

      });
      jScrollPane1.setViewportView(jTable1);
      jTable1.getColumnModel().getColumn(0).setHeaderValue(“Nome”);
      jTable1.getColumnModel().getColumn(1).setHeaderValue(“Status 1”);
      jTable1.getColumnModel().getColumn(2).setHeaderValue(“Status 2”);

      jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(“Imagens”));

      javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
      jPanel1.setLayout(jPanel1Layout);
      jPanel1Layout.setHorizontalGroup(
      jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGap(0, 463, Short.MAX_VALUE)
      );
      jPanel1Layout.setVerticalGroup(
      jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGap(0, 275, Short.MAX_VALUE)
      );

      javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
      getContentPane().setLayout(layout);
      layout.setHorizontalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(layout.createSequentialGroup()
      .addContainerGap()
      .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 375, javax.swing.GroupLayout.PREFERRED_SIZE)
      .addGap(18, 18, 18)
      .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
      .addContainerGap())
      );
      layout.setVerticalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(layout.createSequentialGroup()
      .addContainerGap()
      .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
      .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
      .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 275, Short.MAX_VALUE))
      .addContainerGap(120, Short.MAX_VALUE))
      );

      pack();
      }//

    /**

    • @param args the command line arguments
      */
      public static void main(String args[]) {
      java.awt.EventQueue.invokeLater(new Runnable() {
      public void run() {
      Test test=new Test();
      test.setVisible(true);
      test.InicializaAlternaciaDeSelecao();
      test.InicializaStatus1();
      test.InicializaStatus2();
      }
      });
      }

    // Variables declaration - do not modify
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable1;
    // End of variables declaration

}
[/code]