Let me clear some things:
I’m using JFrame to render all game objects (bg image, game objects, huds etc.). For that i’m not using any swing components (except the JFrame itself).
At the end of the game i’m using JPanel as high scores menu. The panel uses text field for the name and two buttons.
When i try to enter text in the text field the game hangs after few seconds (with no exception but i can point the line it happens in the code).
The rendering is quite simple and looks something like this (gameFrame is the JFrame):
gameObjects.render(g);
gameFrame.getLayeredPane().paintComponents(g);
When the game hangs it always happens in the second line above.
I’m using some other menus with buttons only and they never cause any problems.
At first i used regular JTextField and when i realized it causes problems i subclassed it and synchronized the setText method (…synchronized (getTreeLock()) but it didn’t work either.
I managed to prevent the locking by using EventQueue.invokeAndWait to call gameFrame.getLayeredPane().paintComponents(g) but i don’t like this “solution” because it forces me to wait and use another thread.