views:

35

answers:

1

Hi,

i'm working on a swing program to display several pictures. And one can rotate the picture (implemented each as a JComponent).

Problem is, when a picture gets rotated, the border of the JComponent doesn't change so that the picture gets clipped.

Is there any way to also rotate the border so that the picture can be fully drawn?

(I know one can calculate the new size of the border, but it leaves empty space on the edge. When a rotated picture overlaps with another and one want to move the one underneath, one cannot do that because the event will be passed to the picture above, onto the transparent edge. So it is more ideal if one can just rotate the border).

Thank you very much!

Cheers, Shuo


EDIT I have since no longer put the pictures each in its own JComponent rather flatly in the super panel. Mouse events are translated into AffineTransforms. Now it works great and the cropped border problem no longer exists!

+1  A: 

Execute another pack() on your top-level JFrame after rotating.

Steve McLeod
Thanks! However, we are using null layout for the content pane.. so it's hard to call pack(). I've now implemented the pictures no more in its own JComponent rather direct in the content pane. Mouse events are translated into AffineTransform to the image. And there's now no more border problems!
zavié