嗨,我遇到了Java JTable的问题。 我想合并或跨越细胞。 我用这个例子做到了:
http://www.java3z.com/cwbwebhome/article/article5/swing_example/JTableExamples4.html (最后2个)
它工作但标题和单元格宽度不同。 当有20列以上时,问题就会出现问题,最后一个单元只出现一半。 有谁知道如何解决同步单元格和标题的问题? 有没有人有另一个CellSpan示例/方式?
如果有人试图运行这个例子会得到StackOverFlow错误,要解决,只需改变这一行: setColumnIdentifiers(columnNames); to columnIdentifiers = columnNames; 在AttributiveCellTableModel类。 提前致谢!!
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!!
最满意答案
这里有相同的例子。 似乎问题可能出在MultiSpanCellTable getCellRect()实现中。 列边距有助于单元格宽度并生成此偏移。 看起来如果你更换问题就会消失:
cellFrame.width = aColumn.getWidth() + columnMargin;有:
cellFrame.width = aColumn.getWidth();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();更多推荐
发布评论