Merge de células numa JTable

4 respostas
D

Boa tarde :D,

Como faço merge de células numa JTable?

Aguardo respostas,

Danielle

4 Respostas

tnaires

Oi Danielle, fiz uma rápida busca no Google e achei este artigo. Veja se te ajuda:
http://www.codeguru.com/java/articles/139.shtml

Baixe o código fonte anexado e dê uma olhada.

D

Oi,

Já achei este código, só que o danado é bem complicadinho…
Consegui colocar pra rodar, só que os dados da minha JTable não aparecem mais :cry:

Alguma idéia?

Utilizei o código desta forma:

AttributiveCellTableModel ml = new AttributiveCellTableModel(table.getRowCount(),table.getColumnCount());

CellSpan cellAtt =(CellSpan)ml.getCellAttribute();

MultiSpanCellTable table = new MultiSpanCellTable( ml );

int totalLinhas = table.getRowCount();

int[] columns = {0,1,2,3,4};

int[] rows    = {totalLinhas-1};

cellAtt.combine(rows,columns);

table.clearSelection();

table.revalidate();

table.repaint();

Agradecida,

Danielle

tnaires

Quais são os dados que você está tentando exibir?

Veja que nesta linha:

AttributiveCellTableModel ml = new AttributiveCellTableModel(table.getRowCount(),table.getColumnCount());Você está tentando pegar as linhas e as colunas de uma tabela que não foi inicializada ainda.

marcosvidolin

Olá DanielleCDFS…

apenas uma dica…
coloque o código que postar entre as tags CODE.

Att.

Criado 25 de janeiro de 2010
Ultima resposta 25 de jan. de 2010
Respostas 4
Participantes 3