Headers
What if we want to change the header of a column at runtime? This couldn't be more easier:
table.setColumnHeader("Column 1", "There you have, a new header");
In the preceding line of code, the first parameter is the property ID for the column, and guess what! The second parameter is the new header text. You can change all headers with a single call:
table.setColumnHeaders(new String[] {"Header 1", "Header 2"});
Are you interested in getting an array with the current column headers? There you go:
String[] columnHeaders = table.getColumnHeaders();
Maybe just the header for one particular column:
String columnHeader = table.getColumnHeader("Column 1");
You must provide the property ID of the desired column in the previous call.
Would you like to build a table with no header at all? Ok, that's easy:
table.setColumnHeaderMode(ColumnHeaderMode.HIDDEN);
Hey wait! That was indeed easy but kind of obscure though. That's right. ColumnHeaderMode
is an enumeration that allows you to control what's going...