File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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!