Ok, I use the flowchart editor in Java. My goal is to provide the ability to display grid lines on the surface of a drawing. I partially did this to work:
public void paintComponent(Graphics g)
{
super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g;
g2.transform(transformation);
if(showGrid)
{
for(int i = -1; i < getSize().getWidth(); i += 50)
{
g2.drawLine(i, 0, i, (int)getSize().getHeight());
}
for(int i = -1; i < getSize().getHeight(); i += 50)
{
g2.drawLine(0, i, (int)getSize().getWidth(), i);
}
}
}
The results look like this: 
But if I scroll the chart up or down, I get the following:

As you can see, the chart scrolls, but not the grid. I also tried putting the Step one code before the line g2.transform (transform), but after that, if I scroll, the grid lines do not move.
So the question is: is there a way to draw grid lines and avoid the mentioned behavior? The goal is to scroll the grid along with the other elements in the diagram.
source
share