dimanche 1 février 2015

Stack OverFlow with inherited JPanels


Vote count:

0




So I'm writing a program that is fairly expansive and had a stack overflow error (No, I'm not using any kind of recursion, at least not directly.) I tried to recreate the situation with much simpler classes to see if it would also cause a stack overflow error and it did. Here they are:


First Class:



public class Thing
{
public static void main(String[] args)
{
OtherThing thing = new OtherThing();
}
}


Second Class:



public class OtherThing extends JPanel
{
protected int s =5;
protected String blah = "asfasd";
public OtherThing()
{
OtherOtherThing thing2 = new OtherOtherThing();
}
}


Last Class:



public class OtherOtherThing extends OtherThing
{
public OtherOtherThing()
{

}
}


This causes a stack overflow bouncing between OtherThing line 8 and OtherOtherThing line 4 (lines im sure are a little off now.)


I know that you can inherit from a class that has inherited from something else, the Java API is full of them. Whats wrong with this example?



asked 1 min ago







Stack OverFlow with inherited JPanels

Aucun commentaire:

Enregistrer un commentaire