posted 12 years ago
This is complicated to explain, but the gist is that the JVM is painting a JPanel to its background color when I don't want that to happen. Or, if I fix that, then one window's outline shows through and appears in the content area of a window that's on top of it.
The UI consists of a JFrame holding a JDesktopPane which holds three JInternalFrame objects. One of these JInternalFrame objects contains an instance of my own class, called STextArea. In some round-about way, the problem seems to be due the fact that STextArea starts a Timer, where each time that the Timer goes off, the action command sets a flag and calls repaint() for STextArea. This flag indicates that the next call to paintComponent() should only draw a caret (in xor mode) and draw nothing else. In the example code shown below, I just have paintComponent() do nothing and return when that flag is set rather than drawing the caret since the problem still manifests.
Here's the code -- I stripped it down as much as possible. If this is executed, you will see three sub-windows, where the one in the rear is titled Problem. Click on the Problem window to bring it to the front. The click on the Messages window at the lower-right to bring it to the front. You'll see that the refresh of the middle Messages window bleeds through to the content area of the Problem window. It bleeds through because of the calls to isOpaque(). However, if I get rid of those settings, then the call to STextArea.paintComponent() causes the JVM to fill the contents with the background color the first time that the Timer goes off.