AspOpener
AspOpener

Reputation: 23

How to align border of jtable columns with groupable header

i am working on groupable Header in JTable. I followed the previous ways mentioned in StackOverFlow and have been able to add groupable header in JTable looking at:

http://www.java2s.com/Code/Java/Swing-Components/GroupableGroupHeaderExample.htm

My problem is that there is an alignment issue between header and column. I want to make both the header and column border in same alignment. As this image shows difference in border of both the header and column:

enter image description here

Please suggest me what should i do.

Upvotes: 0

Views: 281

Answers (2)

Akilesh Balireddi
Akilesh Balireddi

Reputation: 1

I did the code change which helped me to resolve the issue . Hope its helps you

In class : GroupableTableHeaderUI

cellRect.width = aColumn.getWidth() + columnMargin; // Remove the column margin which is adding 1px to the width of the header column

New line will have : cellRect.width = aColumn.getWidth()

In class : ColumnGroup

comment line : // width += margin;

This has helped me to align the table columns and the header column . Please find below image

enter image description here

Upvotes: 0

Peter Hassaballah
Peter Hassaballah

Reputation: 1987

BorderLayout.CENTER is the simple answer, but notice if you want to add more than one item (which is typically the case) then you must understand that when using BORDERLAYOUT.NORTH for example there must exist an object that has a layout of BORDERLAYOUT.SOUTH in that case JAVA understands that these object are on top of each other , same applies to EAST and WEST

Upvotes: -1

Related Questions