This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Other JSE/JEE APIs and the fly likes Rotating the Text in an Applet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Rotating the Text in an Applet" Watch "Rotating the Text in an Applet" New topic

Rotating the Text in an Applet

Ranch Hand

Joined: Nov 30, 2000
Posts: 30
Hi I am generating graphs dynamically in my application. And on the Y-axis i wants to display the Parameter Name along the y-axis. Inorder to do that i need to rotate the text by 90 degrees.
I tried with setTransform() method of Graphics2D object , but it's not rotating the Text..
Thanks in advance...
Amit Agarwal
Ranch Hand

Joined: May 09, 2001
Posts: 92
Hi Satish,
you have to use the AffineTransform class of the java.awt.geom package. Usage:
public void paint(Graphics g)
Graphics2D g2=(Graphics2D)g;
AffineTransform at=AffineTransform.getRotateInstance(Math.PI/2, x, y);
d2.drawString("Y Label",x,y);
g2.setTransform(new AffineTransform()); // reset


I agree. Here's the link:
subject: Rotating the Text in an Applet
It's not a secret anymore!