This is a really strange bug...

I'm doing a 'game' of sorts for Computer Science, and it works wonderfully. We have a main method that initializes things and starts the game loop. The game itself works when GUI.java is executed.

Every method call in the main method is static.

Now, the odd thing is that when that exact same code (copy and paste) is run from a different class, and either executed statically, or even when creating a new object and using that as a reference, both JFrames show up as necessary, but they are EMPTY. Big gaping transparent holes of nothing.

Can someone explain this phoenomenon?

FYI: Here's the main method I'm referring to:

// In class GUI:

public static void main(String[] args) {
	init(); //static 
	Console.run(frame, 808, 635); //Console class is static, frame is static
	panel.paintLevel(); // static
	panel.paintLevel(); // static
	frame.run(); // static
}

And when called externally, either this:

// In External Class:

	GUI.init();
	Console.run(GUI.frame, 808, 635);
	GUI.panel.paintLevel();
	GUI.panel.paintLevel();
	GUI.frame.run();

or this

// In External Class:

	GUI gui = new GUI();
	gui.init();
	Console.run(gui.frame, 808, 635);
	gui.panel.paintLevel();
	gui.panel.paintLevel();
	gui.frame.run();

does the transparent frame effect.

Let me know if you need more information.

I don't think we can provide any insight without seeing the panel and frame classes.

On a side note, your may want to reconsider your design in making everything static and trying to manage the interactions by calling static methods on the objects. The main method should really only be responsible for creating whatever minimal number of objects are needed to set up the environment of your program. All other operations should be performed by those objects themselves.

Try calling the main function of GUI from the external class's method...
This is what actually JVM does...

Is there any package involved?

Also post more code, we'd like to test it on our machines too.

This article has been dead for over six months. Start a new discussion instead.