I need to get an appropriate table size according to a text in a header. It contains abbreviations of czech names of days like: \"Po\", \"Út\", \"St\", atc. but instead of t
I came to solution :-)
I had to change the look and feel before I calculated appropriate column widths. When I did it the other way around, the calculation was out of date.
So I only needed to set the correct widths like this:
table.getColumnModel().getColumn(col).setPreferredWidth(width);
And then change the size of the viewPort like this, because the table's prefered size is now correct.
table.setPreferredScrollableViewportSize(table.getPreferredSize());
Thanks! ;)