Rotate JLabel Vertically

To rotate a JLabel‘s text vertically, you only need to use this class and pass it as a parameter to the JLabel‘s setUI() method. Kudos to the developer who created this class to make it easy for other developers to plug this class in and create a vertical JLabel in an instant.

To use this class, check the code below:

This is the code for the VerticalLabelUI class.

Related Posts Plugin for WordPress, Blogger...

7 comments

  1. lolz. if you use a GUI, you can automatically import classes. just did not want to post them as it would lengthen the code 😉

    but thanks

  2. I tried this and it works after my program is up and I “replace” the panels that use the JLabel, however when the program starts the JLabel is normal. How do I get the UI to paint is vertically all the time?

  3. The implementation is incomplete in that it doesn’t transpose the dimensions returned by getMaximumSize()/getMinimumSize(), doesn’t override getComponentUI() so can’t be used with UIDefaults, neglects baseline and baseline behavior etc.

    It’s a good start though.

    db

Leave a Reply

Your email address will not be published. Required fields are marked *