I changed my application that it uses now a JDesktopPane and JInternalFrame instead of just JFrames. My JInternalFrame has a JPanel as the content pane as it overwrites paintComponent() to draw an image. This works for JFrame but the same code in JInternalFrame gives me a NullPointerException in the overwritten paintComponent() because the result of getGraphics() is null!
When I debug my code, I see that getGraphics() returns null - but the strange thing about it is: if I jump back to the start of the paintComponent() (with Eclipse 'DropToFrame' function), getGraphics() returns an object! So, when I debug the code, set a breakpoint at getGraphics() and rerun the method, the second call of getGraphics() returns the graphics object (and the code continues fine) ... so I worked around this problem with
while (g == null) {
g = getGraphics();
}
this works but has the potential of an indefinite loop. :-(
Is there something different with JInternalFrame?