How do I draw some strings that can be copied?

Hello,I have draw a flow chart in Paintable Cavans, and the string was drawed by java2d drawString(str,x,y) . but I would like to make the strings could be selected and copied,does anyone know how to do it?

This brings you into the pure Java environment. It’s technically possible, but not easy.

You should add your own mouse listener, and keep track of the strings somewhere to bind them to screen coordinates.

See for the Java details

1 Like

You can also split this into a paintable canvas for the lines, and a template canvas for the boxes w/ text. Those templates can more easily copy the text on right click or something.

1 Like

It’s good idea,but hard to me…

thanks,I will try it later.

I’ve done a lot with the paintable canvas, including selecting and moving items dynamically. Where is the string data and positions stored now? Are the positions hard-coded? What I do is copy the string and position to a dictionary, and then check the mouse position with event,getX() and event.getY() when I click the mouse, and then check to see which item is underneath that click, since you know the x/y and size of the label.

1 Like