views:

55

answers:

3

I'm having a bit of trouble with Swing components.

In one JFrame, I have a GLCanvas and a JEditorPane separated by a JSplitPane. This configuration makes display response choppy in both panels.

However, when I place the GLCanvas and JEditorPane each in their own JFrame, display response is great.

I would assume this is because, in the second case, all operations on these components are performed in separate threads. If so, my questions are as follows:

Is it possible to run components in their own threads? Or is there a better way I should be doing this?

Thanks for any help you can provide.

+1  A: 

I think your assumption is incorrect. All Swing draw operations occur on the same thread.

Perhaps you could expand on your description of 'choppy' ? Maybe this is double buffering vs non-double buffering issue?

Kevin Day
By choppy, I mean there is a lag between a keypress and the text in the editor pane being updated. As well, moving the split pane is laggy. I hope this makes sense.
sparrow400
+4  A: 

I suspect that the poor performance in the first case has more to do with Mixing heavy and light components. Like most graphics APIs, Swing uses a single, event dispatch thread to update the screen; I'm guessing that JOGL must adhere to the same restriction. At the same time, there are many ways to perform work in another thread and communicate with the graphics environment.

trashgod
Thanks, This makes sense. I'll investigate this further. Matthew's website seems to be a good starting point.
sparrow400
+1  A: 

Looks like @trashgod is right. GLCanvas is a "heavyweight" component descendent from awt Canvas. To see if it is really a case I suggest replacing GLCanvas with GLJPanel, which is a Swing component descendant from JPanel.

eugener
Good find! This looks like an excellent alternative.
trashgod
I've actually tried this, and while it solves the problem with the lag in EditorPane, it has a much slower refresh rate compared to GLCanvas. I really need to maintain a good frame rate in the rendering view.
sparrow400
I does have slower refresh rate, because of addition overhead of Swing pipeline. As I see it now you really have only one choice - to separate your elements if you want to get rid of the "choppinnes"
eugener