I have a table with 3 columns and want the first one to be the minimum size needed. The header is "Level" and seems to be 25-29 pixels depending on the font/OS I use. However the table header seems to require at least 35 on Windows and 52 on Mac to display it without ellipses. I can't figure out why the extra space is needed (there's no border, etc).
I finally found that the following will give the required size on Windows (35) but on Mac it returns 36 which is not enough (most likely due to the sort arrow indicator being next to, rather than above, the text)...
table.getTableHeader().getDefaultRenderer().getTableCellRendererComponent(null, table.getColumnModel().getColumn(0).getHeaderValue(), false, false, 0, 0).getPreferredSize().width
What's the right way to do this that's platform independent? Or, is there a way on Mac to calculate the extra space needed so that I don't have to hardcode something like adding 15 or so pixels to the above result?