Drawing a line, handles, resize, dragable

Hi,

I would like to draw a line on a JPanel. The user would click and drag to draw it.

If the user clicks on the line, some handles should appear at both ends of the line. The handles disappear if the user click elsewhere.

By dragging a handle around, the user can resize the line.

Lastly, the user should be able to move the line by dragging it.

Unfortunately, I don't know how to do all this.

Do you know if there is any example out there that I could study/copy?

Is there any library that have a component with such functionality?

Thanks for your help.

[613 byte] By [urddda] at [2007-11-27 8:06:45]
# 1

Unfortunately there are no libraries,

i have faced this problem some days ago. You have to use a boolean / int to set the status of the operation like "drawing" or "moving" and deal with the mousedragged event: here you have to change pts of the line /OR/ create the line.

anyway, remember to overraid the method paintcomponent and call it every change you made.

Gio

J_newBiea at 2007-7-12 19:49:23 > top of Java-index,Security,Cryptography...
# 2
A library that does just that? I don't know. But this one can do what you want, including a hell of a lot more: http://geosoft.no/graphics/index.html
prometheuzza at 2007-7-12 19:49:23 > top of Java-index,Security,Cryptography...
# 3

You probably can use a code from Mediajuggler project:

https://mediajuggler.dev.java.net/

It's located at Main.java and CodeLine.java

https://mediajuggler.dev.java.net/source/browse/mediajuggler/trunk/src/mediajuggler/Main.java?rev=88&view=markup

https://mediajuggler.dev.java.net/source/browse/mediajuggler/trunk/src/mediajuggler/CodeLine.java?rev=91&view=markup

AlexeyUshakova at 2007-7-12 19:49:23 > top of Java-index,Security,Cryptography...