How can I change the title text of jTable columns to a vertical
orientation (rotate for example 90 degrees)?
Thanks for any help,
regards
Werner Nussbaumer
You need to write a custom TableCellRenderer that draws its text vertically
and set that as the renderer for the JTableHeader on the table.
--
Daniel Dyer
Empathy Software (http://www.empathysoftware.com)
Thanks. I used:
class CustomTableHeaderCellRenderer extends DefaultTableCellRenderer
{
public Component getTableCellRendererComponent(JTable table, Object
value, boolean isSelected, boolean hasFocus, int row, int column)
{
Component cell = super.getTableCellRendererComponent(table, value,
isSelected, hasFocus, row, column);
cell.setFont(new Font("SansSerif",Font.PLAIN,10));
cell.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
setOpaque(true);
return this;
}
}
But ComponentOrientation has no property for rotating the text.
Do you have an example on how to rotate the text?
Thanks a lot,
regards
Werner Nussbaumer
Sorry I only gave you half an answer, unfortunately I'm not sure about
rotating the text, I've not needed to do it before. Is there maybe some
way to apply a translation to the text before painting it (worst case is
that you could over-ride paint component and paint the text yourself)?
However this works, I don't know, and that's why I asked the
specialists of this newgroup.
Any idea?
Regards
Werner Nussbaumer