Switching Display's parent canvas in JFrame causes freeze

Started by CodeBunny, June 01, 2011, 00:55:10

Previous topic - Next topic

CodeBunny

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.

broumbroum

Ensure you run on the EDT somehow, use JConsole to see whether AWT-Eventqueue Thread is locked.