JTable cell span merge

10,012

The same example is available here. It seems the problem might be in MultiSpanCellTable getCellRect() implementation. Column margin is contributing to the cell width and generating this offset. Looks like the problem goes away if you replace:

cellFrame.width = aColumn.getWidth() + columnMargin;

with:

cellFrame.width = aColumn.getWidth();
Share:
10,012
Guilherme Simão Couto
Author by

Guilherme Simão Couto

Master in Computer Science. PhD student.

Updated on June 27, 2022

Comments

  • Guilherme Simão Couto
    Guilherme Simão Couto almost 2 years

    Hi I'm having a problem with Java JTable. I want to merge or span cells. I did it using this examples:

    http://www.java3z.com/cwbwebhome/article/article5/swing_example/JTableExamples4.html (last 2 ones)

    It works but the header and the cells width are not the same size. The problem agravates when there are more 20 columns, the last cells appear just half. Does anyone know how to solve this problem of synchronizing cells and headers? Does anyone have another CellSpan example/way?

    If someone try to run this examples will get StackOverFlow error,to solve, justo change this line: setColumnIdentifiers(columnNames); to columnIdentifiers = columnNames; at AttributiveCellTableModel class. Thanks in Advance!!