
If you didn’t already know, you can embed simple HTML inside all Swing text components including JLabel. The default renderer for a the column header is a JLabel component. In order to create a multiple row header, simply use HTML markup with a “<br>” HTML separating the rows.
The getColumnName method of the TableModel interface allows you to return HTML since this value will be passed into the JLabel text component.

One important thing to understand is the height of all header columns is determined by the height of the first column.


If the the first column is only a single row/line, and the others are multiple rows, then use “ ” on the first column to create an empty row.

Was this helpful? Did you already know this trick? Leave my a comment.
Related posts: