I got another related problem now. It seems absurd. I thought the point with using Swing was that you would not need to control buffers, active rendering and not having to take any consideration whatsoever of graphic memory or platform. Just being able to use paintImmediately when i needed something urgently painted and then use some sleep(millis) before some operations preventing that the paintImmediately did not interfer and create strange graphic bugs. Seems I was wrong…
Now, the problem is when i ALT+TAB out from and then back into the game. If I have a JDialog on the Screen when i do this, it will be invisible when i return but still be active internally. It is “like it is there”, I have to close it down on invisible JDialogs close button.
I tried setIgnoreRepaint(true) by making a MyJPanel extends JPanel using it for all my JPanel in the game. MyJPanel sets “this.setIgnoreRepaint(true);” .
I even tried to close the JDialog when ALT+TAB i.e using eventhandler to close all dialogs when losing focus
void this_focusLost(FocusEvent e) {
this.blablablaDialog.hide()
…
…
…
}
and it does not work! JDialog is still there, but invisible, when i return (in both modal and non-modal JDialog). ???
I am soon convinced that Swing cannot even be used purely to make turn based strategy games with its limit so maybe I would have to be forced switching to Active Rendering and paintingloops(). :
By the way, with Active rendering, I could not use Swing JPanel on the screen because i would paint over them from the painting loop? So, i need to make every little JLabel, JButton and all that from the painting loop and not using Swing layout managers?