Hello does anyone out there know how to change the angle of a JButton from horizontalto lets say at an angle of 45 degress or even 55 degrees or even how to rotate a JButton? yours respecfully Avin Sinanan
Hi Natan, I have been tru' you code of the AngledButton & I have been quiet impressed because I don't understand exactly what you are doing with it. More specifally what you do there in the paint & paint Border methods
Could you give some more hints on why you are calculating these points & what they are for ? I am also very much puzzled by the need to do the clipping & the need to redraw the old version of the Button ! Would it be possible to have a few indication on they needs & they reasons ? Thomas SMETS, SCJP2 - Brussels
I believe the problem is this... when you rotate the button at an angle, the button still has the same "size", so, you only get the rotated button drawn in the area that the non-rotated button would occupy. If you change the size of the displayed area, you are changing the size of the button, so I had to figure out some way to draw the button using the super.getPreferredSize(), but display the button in an area large enough the show all of the rotated button. That is accomplished through the overridden paint() method. The paintBorder() method also had to be messed with because the border is drawn based on the size.
Hopefully this answers your question... if not, I can take a more in depth look at the code and help out some more...
Write once, run anywhere, because there's nowhere to hide! - /. A.C.