title: Java 1.5 JOptionPane paint bug when using panel message/workaround?
body: <p>I have a JOptionPane with a custom message panel in it, in an application targeted for Java 1.5. The panel contains, among other things, a JTextField. Every 20 invocations or so, nothing in the dialog gets painted (not even the OK/Cancel buttons). If I drag the dialog off the screen and back again to force a repaint, the components are visible as expected, and apart from the painting problem, the components respond fine. Here is the smallest example I could get to exhibit this bug:</p>
  
  <pre><code>public class BugTest {
    public static void main(String args[]) {
      SwingUtilities.invokeLater(new Runnable() {
        public void run() {
          // The text field needs to be wrapped in a panel for the bug to show up.
          JPanel messagePanel = new JPanel();
          // A JLabel won't exhibit the bug, but a JTextField will.
          JTextField textField = new JTextField("Some content");
          messagePanel.add(textField);
          // Loop so we can keep clicking OK until the bug shows up.
          while (true) {
            int res = JOptionPane.showOptionDialog(null, messagePanel,
                "SomeTitle", JOptionPane.OK_CANCEL_OPTION,
                JOptionPane.PLAIN_MESSAGE, null, null, null);
          }
        }
      });
    }
  }
  </code></pre>
  
  <p>Is this a well-known bug in Swing? Is there a standard workaround? I haven't been able to find an official bug report for this. The bug does not appear to be present in Java 1.7, but my application needs to run on the older 1.5, and I'd like to find a workaround that works on the latter.</p>
  
  <p>Related: <a href="https://stackoverflow.com/questions/5362090/modeless-jdialog-not-showing-contents">Modeless JDialog not showing contents</a> (does not include a code example, so it's hard to know if it's the same bug)</p>
  
  <p>The specific Java version I've found the bug on is 1.5.0_22.</p>