Pessoal estou usando um table model e estou em uma das colunas querendo colocar um JTextArea
Só que da forma que eu estou tentando está dando erro…
alguem pode me dar uma dica ?
rs…
[code]/*
- To change this template, choose Tools | Templates
- and open the template in the editor.
*/
import java.util.ArrayList;
import java.util.List;
import javax.swing.JTextArea;
import javax.swing.table.AbstractTableModel;
/**
*
-
@author Rodrigo
*/
public class CaixaEncomendaTableModel extends AbstractTableModel {private List lista = new ArrayList<>();
private final int COL_DESCRICAO = 0;
private final int COL_ALTURA = 1;
private final int COL_LARGURA = 2;
private final int COL_COMPRIMENTO = 3;public List getLista() {
return lista;
}public void setLista(List lista) {
this.lista = lista;
}@Override
public String getColumnName(int column) {if (column == COL_DESCRICAO) { return "Descrição"; } else if (column == COL_ALTURA) { return "Altura"; } else if (column == COL_LARGURA) { return "Largura"; } else if (column == COL_COMPRIMENTO) { return "Comprimento"; } return "";}
@Override
public int getRowCount() {
return lista.size();
}@Override
public int getColumnCount() {
return 4;}
@Override
public Object getValueAt(int rowIndex, int columnIndex) {CaixaEncomenda caixaEncomenda = lista.get(rowIndex); if (columnIndex == COL_DESCRICAO) { JTextArea ta = new JTextArea("opa!\n\n\n\n\n\n\n\n\nFim"); return ta; } else if (columnIndex == COL_ALTURA) { return caixaEncomenda.getAltura(); } else if (columnIndex == COL_LARGURA) { return caixaEncomenda.getLargura(); } else if (columnIndex == COL_COMPRIMENTO) { return caixaEncomenda.getComprimento(); } return "";}
}
[/code]