当前位置: 动力学知识库 > 问答 > 编程问答 >

java - How Do I Rotate A Widget In NetBeans Visual Library?

问题描述:

I am building a document layout editor in NetBeans Visual Library API, and I am looking for a way to let the user rotate a widget about it's center with the mouse. How would I go about adding this functionality?

UPDATE

I think I need to clarify, this is what I want to accomplish:

  1. User clicks on a Widget in my NetBeans Visual Library API based document layout editor
  2. User drags the mouse. As the user drags the mouse the Widget rotates about it's center
  3. User release the mouse button. The Widget remains in the rotated position.

I am not using an NetBeans Platform or an IDE.

网友答案:

Looking at the API doc for Widget, I don't see how it is possible.

There is another approach I can suggest.

extend Widget (the relevant widget you are interested in), add support for rotation. In paintWidget method, add a line

graphicsContext.rotate(angle)

The angle will have to come from your model or user interaction. How you build the user interaction is another exercise, but this approach should work.

If you need something which is already provided, then simply copy the source in your own class and add support for rotation.

If you have already come across a better way, I would be happy to learn about it.

分享给朋友:
您可能感兴趣的文章:
随机阅读: