Reputation: 23
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:
Please suggest me what should i do.
Upvotes: 0
Views: 281
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
Upvotes: 0
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