LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: CodeBunny on June 01, 2011, 00:55:10

Title: Switching Display's parent canvas in JFrame causes freeze
Post by: CodeBunny on June 01, 2011, 00:55:10
The following code freezes my application, but no error is printed to the console. It looks like some sort of livelock/deadlock issue, but I can't determine the source.

The goal is to have the option to shift the Display from one canvas to a different one.

Here's a (slimmed down) version of the code:

public void setDisplayTo(Canvas canvas)
{
if(canvas != Display.getParent())
{
Display.getParent().removeComponentListener(this);
try
{
Display.setParent(canvas);
Display.getParent().addComponentListener(this);
}
catch (LWJGLException e)
{
e.printStackTrace();
}
}
}


So: How can I get this to work? Or should I not bother with this functionality? I was going to add it for completion's sake, but it's not very necessary.
Title: Re: Switching Display's parent canvas in JFrame causes freeze
Post by: broumbroum on June 01, 2011, 22:56:43
Ensure you run on the EDT somehow, use JConsole to see whether AWT-Eventqueue Thread is locked.