A long time ago I wanted to have a component which could paint rotated text for my application
I definitely could create my own component, override paintComponent(), implement correct resizing etc...
Yes, it was clear how to implement your own rotatable JLabel, but what if I want to have a rotatable JButton and I want to have it for each Look and Feels, how many classes I would have to sublclass in this case?
At the same time Swing controls the entire painting routine using the power of Java2D library and there is Graphics2D.setTransform(AffineTransform Tx)method which can scale, rotate and shear Graphics2D instance.
It sounded like a good starting point and I decided to quicky implement a Swing container which can transform its children component without affecting its functionality.
Nevertheless, this task turned out to be so challenging so I spent about 3 months looking for the best solution from time to time. (I feel I am ready to give a lecture about the long way to the current implementation :-))
My goal was to implement it using public interfaces only with no reflection hacks and with no affecting the whole system (no custom EventQueue, custom RepaintManager or AWTEventListener) because it would allow using the component in restricted evironments like WebStart applicaitons
Finally I am happy to present the result: to rotate your JButton just do
JButton button = new JButton("Hello");
JXTransformer t = new JXTransformer(button);
And you'll have a rotated and live button, which works like a usual JButton
Check the WebStart demo and play with three bottom sliders
Source and demo files are published on SwingHelper.dev.java.net and don't forget to check CheckThreadViolationRepaintManager andEventDispatchThreadHangMonitor as well
Check it, Test it, Use it and send your valuble feedback !
The JXTransformer is pretty hacky sometimes, so if you believe we should better support things like that for the next JDK leave a comment here
Note: JXTransformer is an experimental project and has several known limitations