I want to draw the lines between 2 JScrollPanes (first scroll pane on the left side, second on the right). These JScrollPanes contain images. I want to draw lines between these 2 images (use some layers, use some trick etc.). I tried do it different ways, but i failed. Is it possible? (if not, i will have to make 2 images in one JScrollPane and it won’t be nice).
EDIT
I want to draw between 2 images – throught components – get some points from images and draw lines between them. I apologize for poorly formulated question.
In order to accomplish this, I believe you’ll need to make use of the
Glass Pane. TheGlass Panesits on top of everything in theJRootPaneand fills the entire view. This particular position allows two distinct capabilities:I believe your question is addressed by the second capability. The following is an example implementation, which you can later tailor to meet your own needs. Note that I’ve left out a lot of detail with regard to
Glass Panethat you’ll need to research on your own.CODE
OUTPUT
EXPLANATION
In this example, I clicked two arbitrary points within each
JLabel, and then drew a connecting line.