Brad
Joined: 26 May 2004 Posts: 2
|
Posted: Tue Apr 26, 2005 2:27 pm Post subject: ToolTips on TableColumn headers |
|
|
The SRP calendar is built from a java JTable. Java JTables have TableColumns which in turn have a header object which is accessed via the TableColumn's getHeaderValue method. By default this header is a String object populated with the TableModel's getColumnName method. To have tool tip text for the TableColumn header replace the String object with a JLabel.
| Code: |
JLabel myNewJL = new JLabel(myTableColumn.getHeaderValue().toString());
myNewJL.setToolToolText(myTableModel.getSomeToolTipText(myColumnIndex));
myTableColumn.setHeaderValue(myNewJL);
|
In your TableModel you will have to write a getSomeToolTipText(ColumnIndex) to get the appropriate tool tip text for this column.
And further now that you have replaced the default header with a JLabel you have a many many options for customizing your header.
Room for improvement: Why is the TableColumns header a String by default? What if getColumnName could return the object for the header instead of a String? |
|