How are you rotating the text? By tweaking paint? You will have to use the FontMetrics to figure out the dimensions of the rendered font and then tweak the g.drawString()'s 'x' and 'y' co-ordinates accordingly.
Just out of curiosity, what exactly are you trying to do here by rotating the text?
the above code turns the text 270 degrees and the text is always align to right side and how to make it as center alingment.
Rotating 270 degrees means making it upside down. So your left becomes your right and you are setting it at 0,0.
Like I said before, you need to use the FontMetrics and adjust your 0,0 accordingly. Also check out This is a nice article which uses text rotation for getting Adobe style tabbed pane tabs.
Joined: Jul 07, 2008
That code works fine and i aligned at center when i was change that line of code to g2.drawString(this.getText(), 8, -52); but here one problem is that the rotated text added to JTableHeader,i was unable get both horizontal lines and vertical lines, it can applied for row data only not for the JTableHeader.