Hello,
I am programming a game and using Swing as my GUI. I did some changes, so I can have a custom GUI. This is what I have done:
I have made the game map a JLabel on a JFrame. Then I have overridden the JLabel so that I can have movable windows, placed on top of this game map(that is a JLabel). This works fine, and all is well.
The problem is that I have to call the repaint of the game map 10 times a second (More on this later). What occurs is a repaint to all of the game label’s children are done. So, my GUI gets repainted 10 times a second. This causes a great performance decrease and I am not too pleased with it.
Does anyone know how to only repaint what is on the game label and not the children (yet still make sure they render correctly)? I know there is a way to ignore repaints, but I believe that is only for hardware calls, and not software.
The performance decrease I speak of is my dual core CPU runs at 20-25% during repainting. I have done some modifications, so that if I do not need to draw (fast moving projectiles, these draw at 100 MS), I won’t draw (there are no projectiles to draw). Character movement is done at 250 MS, so if I do not need to draw 10 times a second, I will draw at least 4 times. This keeps the CPU down to 8-12%, which is more acceptable.
From my investigations, it seems I am out of luck.
Thanks for any advice/help!
PS: I wanted to try this forum first before going to Sun’s.