Whats wrong with that code?
<p>I have a problem with the following code: </p>

<pre><code>import java.applet.Applet;
import java.awt.Color;
import java.awt.Graphics;    

public class Fraktalz extends Applet{

private static final long serialVersionUID = 1L;
Graphics grafika;   

public void paint(Graphics g){
    g.setColor(Color.white);
    g.fillRect(0, 0, 640, 480);
    g.setColor(Color.black);
    smok(200,360,500,120,20);


}


public void smok(int x1, int y1, int x2, int y2, int iteracja){
    if (iteracja == 0){
        grafika.drawLine(x1,y1,x2,y2);
    } else{
        int cx = (x1 + x2) / 2;
        int cy = (y1 + y2) / 2;

        int x3 = cx + (y2 - cy);
        int y3 = cy + (x2 - cx);

        smok(x1,y1,y3,y3,iteracja-1);
        smok(x2,y2,x3,y3, iteracja-1);
    }
}   

public static void main(String[] args) {
    javax.swing.SwingUtilities.invokeLater(new Runnable() {

        public void run() {
            new Fraktalz();

        }
    });
}
}
</code></pre>

<p>It says I got a <code>nullPointerException</code> at <code>Graphics grafika;</code>
When I've done:</p>

<pre><code>Fraktalz fr = new Fraktalz();
Graphics grafika = fr.getGraphics();
</code></pre>

<p>I got an error: </p>

<pre><code>Exception in thread "AWT-EventQueue-0" java.lang.StackOverflowError
    at java.lang.Class.getClassLoader(Unknown Source)
    at java.awt.Component.checkCoalescing(Unknown Source)
    at java.awt.Component.&lt;init&gt;(Unknown Source)
    at java.awt.Container.&lt;init&gt;(Unknown Source)
    at java.awt.Panel.&lt;init&gt;(Unknown Source)
    at java.awt.Panel.&lt;init&gt;(Unknown Source)
    at java.applet.Applet.&lt;init&gt;(Unknown Source)
    at Fraktalz.&lt;init&gt;(Fraktalz.java:6)
    at Fraktalz.&lt;init&gt;(Fraktalz.java:9)
    at Fraktalz.&lt;init&gt;(Fraktalz.java:9)
</code></pre>

<p>Can somebody help me with that error?</p>
