title: Java java.lang.StackOverflowError on New Class Object Creation: possible recursion?
body: <p>Getting an error when creating an object from a class. </p>
  
  <pre><code>public class Game extends Form {
  
  private GameWorld gw;
  
  private int lives;
  private int clock;
  
  public Game() {
  
      // initialize game
      init();
      System.out.println("before gameworld: ");
  
      gw = new GameWorld();
  
      System.out.println("after gameworld: ");
      gw.init();
      play();
  }...
  </code></pre>
  
  <p>Program iterates, prints before Gameworld and goes to line below then repeats.</p>
  
  <pre><code>gw = new GameWorld();
  </code></pre>
  
  <p>Gameworld Class</p>
  
  <pre><code>public class GameWorld extends Game {
  
  private int gameWidth;
  private int gameHeight;
  
  public GameWorld(){
  
      //init();
  
      System.out.println("after inititalization");
  }...
  </code></pre>
  
  <p>Getting the following error in Eclipse on run. </p>
  
  <pre><code>java.lang.StackOverflowError
  at com.codename1.ui.plaf.DefaultLookAndFeel.getPreferredSize(DefaultLookAndFeel.java:675)
  at com.codename1.ui.plaf.DefaultLookAndFeel.getLabelPreferredSize(DefaultLookAndFeel.java:665)
  at com.codename1.ui.Label.calcPreferredSize(Label.java:484)
  at com.codename1.ui.Component.preferredSizeImpl(Component.java:1985)
  at com.codename1.ui.Component.preferredSize(Component.java:2020)
  at com.codename1.ui.Component.getPreferredSize(Component.java:782)
  at com.codename1.ui.Component.getPreferredW(Component.java:862)
  at com.codename1.ui.layouts.BorderLayout.getPreferredSize(BorderLayout.java:440)
  at com.codename1.ui.Container.calcPreferredSize(Container.java:1848)
  at com.codename1.ui.Component.preferredSizeImpl(Component.java:1985)
  at com.codename1.ui.Component.preferredSize(Component.java:2020)
  at com.codename1.ui.Component.getPreferredSize(Component.java:782)
  at com.codename1.ui.Component.getPreferredH(Component.java:872)
  at com.codename1.ui.layouts.BorderLayout.positionTopBottom(BorderLayout.java:414)
  at com.codename1.ui.layouts.BorderLayout.layoutContainer(BorderLayout.java:284)
  at com.codename1.ui.Container.doLayout(Container.java:1420)
  at com.codename1.ui.Container.layoutContainer(Container.java:1412)
  at com.codename1.ui.Container.revalidate(Container.java:1058)
  at com.codename1.ui.Toolbar$ToolbarSideMenu.initMenuBar(Toolbar.java:1233)
  at com.codename1.ui.Form.setMenuBar(Form.java:3229)
  at com.codename1.ui.Form.setToolbar(Form.java:3250)
  at com.codename1.ui.Form.initGlobalToolbar(Form.java:218)
  at com.codename1.ui.Form.&lt;init&gt;(Form.java:210)
  at com.codename1.ui.Form.&lt;init&gt;(Form.java:166)
  at com.mycompany.racecar.Game.&lt;init&gt;(Game.java:19)
  at com.mycompany.racecar.GameWorld.&lt;init&gt;(GameWorld.java:8)
  at com.mycompany.racecar.Game.&lt;init&gt;(Game.java:25)
  at com.mycompany.racecar.GameWorld.&lt;init&gt;(GameWorld.java:8)
  at com.mycompany.racecar.Game.&lt;init&gt;(Game.java:25)
  at com.mycompany.racecar.GameWorld.&lt;init&gt;(GameWorld.java:8)
  at com.mycompany.racecar.Game.&lt;init&gt;(Game.java:25)
  at com.mycompany.racecar.GameWorld.&lt;init&gt;(GameWorld.java:8)
  at com.mycompany.racecar.Game.&lt;init&gt;(Game.java:25)
  at com.mycompany.racecar.GameWorld.&lt;init&gt;(GameWorld.java:8)
  at com.mycompany.racecar.Game.&lt;init&gt;(Game.java:25)
  at com.mycompany.racecar.GameWorld.&lt;init&gt;(GameWorld.java:8)
  at com.mycompany.racecar.Game.&lt;init&gt;(Game.java:25)
  at com.mycompany.racecar.GameWorld.&lt;init&gt;(GameWorld.java:8)
  at com.mycompany.racecar.Game.&lt;init&gt;(Game.java:25)
  </code></pre>
  
  <p>What am I doing wrong? Why is it looping so much? </p>