Can you make a small complete program that compiles, executes and shows the problem.
The posted code does not show what is in g2d