File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Inclined Text of JLabel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Inclined Text of JLabel" Watch "Inclined Text of JLabel" New topic

Inclined Text of JLabel

kumarjit banerjee
Ranch Hand

Joined: Mar 27, 2011
Posts: 32


I have worked on some basic application in java swing, such as reading a text from JTextField, or implement some logic on the event generated by JButton. I have gone thorough the topics in the internet of how to create a button of custom shape as compared to JButton which is rectangular in shape. I want to know is there someway to display the text in the JLabel in an inclined way. I have attached an image for clarification. Suppose I want to create JLabel as

It will display the text JLabel as the text in the image (left side)
I want to display the text as in the image at the right side

Please suggest me how can I achieve this.

[Thumbnail for JLabel.JPG]

Luigi Plinge
Ranch Hand

Joined: Jan 06, 2011
Posts: 441

No easy way, but see Rob Camick's page Rotated Icon, and set the label as an icon.

There's an a tutorial on text manipulation here that might be useful, if you see the section "An New Slant on Text" and apply a different AffineTransform.
I agree. Here's the link:
subject: Inclined Text of JLabel
It's not a secret anymore!