Hey guys,

I've constructed the main class to refer to a variable in it and I receive a stack overflow error. Any suggestions on the causes of this error, I've used this method previously and have not got this before.

In other class:

MainClass class = new MainClass();

errors:

Exception in thread "main" java.lang.StackOverflowError
	at java.awt.Insets.<init>(Insets.java:86)
	at sun.awt.windows.WToolkit.getScreenInsets(Native Method)
	at sun.awt.windows.WToolkit.getScreenInsets(WToolkit.java:549)
	at java.awt.Window.init(Window.java:395)
	at java.awt.Window.<init>(Window.java:433)
	at jav

       . . . and so on

Cleo

This also opens a new frame of the main class, just want to refer to it's variable!

somewhere in the ... and so on it gives details of the lines in your program that it was executing when it overflowed. This is essential info. Anyway, it looks like it's in the middle of creating a window, so your loop is probably in the creation of the new frame, and is probably recursive. Can you post the code?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.