As a workaround, I implemented a TableHeaderCellDecorator to do what I wanted using icons so that resizing the table header works like there was no icon. It would be nice if it factored in icons though.
There is also another problem with the header line wrapping cutting off text when we don't expect it to. If one header has a single string value and another has two, we would expect the second to wrap, but instead the header collapses to one row and cuts off the text. As a workaround, I had to create a JViewPort to set a reasonable maximum height given the header line wrap model values of:
- Code: Select all
@Override
public int getPreferredRows(final int column) {
return 2;
}
@Override
public int getMaximumRows(final int column) {
return 3;
}
@Override
public int getMinimumRows(final int column) {
return 1;
}
@Override
public int getPreferredWidth(final int column) {
return -1;
}
I have fought with values that worked for all header values, but some tables just don't wrap correctly when sorting the first column that spans two rows (like "Compare Index").
It would also be nice if there was an option to set the values for a HeaderLineWrapModel to switch between no line wrapping to line wrapping with 1,2,3, etc. rows or fitting the contents of the header to fit exactly without having to increase the view port size of the header while changing the values in the line wrap model. I implemented a table header pop-up to let the user select custom values or select a header wrap option for NO_WRAP, WRAP, FIT, or another called COMFORTABLE with default values and it sort of worked. Once we started increasing the preferred and maximum rows, we also had to adjust the view port to fit the header; otherwise, it would cut off the header and ignore our values.