This is not the way it works
OK have your DotPanel
You don't need (and don't want) a Graphics2D instance variable
When the GUI will determine that you need to repaint your panel (component added, frame resized, another window over your app, ...) it will call the paint() method of your DotPanel passing to it the Graphics object to use. (Not the one you think you have stored/saved/created)
If you decide that you want to redraw your panel according to a context change in your application do: d.repaint() (d beging your DotPanel instance) and wait for the GUI ( afew milliseconds) to call back your paint() method whith the Graphics object to use
Then in your paint() method you can draw what you want (you can cast the Graphics object to a Graphics2D object if you plan to use a Graphics2D method)
CODE
public void paint(Graphics g) {
Graphics2d g2 = (Graphics2D) g; // local variable not an instance one
g2.setColor(....
g2.DrawOval(....
}