Pegando valor de row + AbstractTableModel [RESOLVIDO]

1 resposta
R

Estou tentando pegar o valor de uma coluna de um table model. Porem retorna null!

Alguem tem alguma ideia do que pode ser?

Pegando o valor no Frame:

if (e.getSource() == btEncaminhar) {

            Movimentacao mov = new Movimentacao();

            mov.setCd_documento((String) jTable1.getValueAt(jTable1.getSelectedRow(), 0 ));

Table Model getValueAt() :

public Object getValueAt(int row, int column) {

        PendenciaRecebidos precebido=precebidos.get(row);
        //if(column==COL_CD_DEPTO) return depto.getCd_depto();
        /*else*/

        if (column == COL_CD_DOCUMENTO) {
            return precebido.getCd_documento();
        }

1 Resposta

R

Tinha que usar uma variavel para armazenar o valor da linh, depois uma String para armazenar o valor da Celula.

int k = jTable1.getSelectedRow();

String cd_documento=(String) jTable1.getValueAt(k, 0 );

mov.setCd_documento(cd_documento);

Criado 1 de junho de 2010
Ultima resposta 1 de jun. de 2010
Respostas 1
Participantes 1