0

I know there are many other posts about how to rotate an JLabel on the forum. But they all talk about rotating the imageIcon inside the jLablel. I would like to know if its possible to rotate the label itself.

My requirement is that I have a label that is a straight line. Not I would like to rotate it dynamically based on other things on the panel. Now if I just rotate the imageIcon by say 45 degress, the new label would take more space and probably overlap other components.

I hope, I framed my question properly.

Newbie
  • 129
  • 1
  • 3
  • 11
  • This [example](http://stackoverflow.com/a/6333584/230513) illustrates some to the trade-offs. – trashgod Nov 22 '13 at 21:17
  • `Now if I just rotate the imageIcon by say 45 degress, the new label would take more space and probably overlap other components.` - why do you think rotating a JLabel will be any different? Your component would only be the same size through all rotations if you have a circular image. – camickr Nov 22 '13 at 21:17
  • I was thinking that if I rotate the label, it would only take up that amount of space and not increase the height and width of the label. Am I totally wrong here? – Newbie Nov 22 '13 at 21:19
  • So you want to truncate the image? The corners of the image will be outside the bounds of the label if you keep a fixed size. – camickr Nov 22 '13 at 21:21
  • It can be done using some like JXLayer, take a look at [this example](http://stackoverflow.com/questions/14324460/rotating-a-jtextfield-vertically/14328881#14328881) which rotates a `JTextField` but the basic requirements are the same... – MadProgrammer Nov 22 '13 at 22:43

0 Answers0