If dragging the frame messes up the displayed graphics, this indicates a redraw problem. How do you draw and redraw the graphics output?
You should use paint(Graphics g) to do the painting, and you should expect this method to be called each time the window needs to be refreshed.
You should not use getGraphics() outside the paint() method to get a graphics context and draw into it - that is not the way this method is supposed to be used, and it does not work reliably.
Actually, the story is more complex for JFrame. Since this is a container, it is expected to contain child components, and therefore there is a method paintComponents(Graphics g) which must ensure that all child components are painted. If you overwrite paint(Graphics g), you should call super.paint(g) to ensure that the paintComponents(g) method is called, or you should call it directly (the former is cleaner, as you cannot know what else happens in the original paint method).
The best way to have custom content painted is to extend JComponent to have a custom component, and then add this component to the JFrame.