Search code examples
javaswingrotationjtextarea

Rotating the JTextArea using mouse in java


I recently worked on the MS PowerPoint 2007 and I got interested in rotation option of the text in the presentation Window .

Now I have created a JTextArea with some text in it.

Now what I want is I want to rotate the JTextArea by mouse (similar in MS PowerPoint 2007)

But I got no Idea of how to start .

Thanks in advance


Solution

  • If you just don't know how to start, here is a hint:

    • implement a MouseMotionListener to track the MousePosition
    • to rotate components you can override their paintComponent(Graphics g) method and rotate with ((Graphics2D)g).rotate(degreeInRadians). Keep in mind that this probably crops your components.