I have a class that inherits from JPanel. It is called DrawingPanel and in this class I draw lines and shapes using Graphics2D and I use the position of user's mouse to do some operations on these shapes.
The drawings in the panel can take a lot of space on screen (for instance I may draw lines from (-200, -300) to (2000, 1000)), so actually I only see a part of the drawings. That's why I would like to be able to move all things drawn in my panel with scrolling.
Is there a simple and elegant solution to do this, and that would not require too much changes in my code?
EDIT: Actually my problem is that I don't know an elegant way to have scrolling working in a JPanel with shapes drawn with Graphics2D. I tried to add my JPanel to a JScrollPane but it did not worked. Practically, what should I have to add to my code?