title: Ensure that AWT Canvas is drawn on-screen before doing something else
body: <p>In my application I NEED to make sure that Canvas is actually appeared on the screen before going for the next step. The reason is that I need to retrieve an AWT Drawable - i.e. the native window surface of that canvas. And that drawable would be invalid if the canvas is not visible, even if it has the flag &quot;visible&quot; set to true.</p>
  <p>The problem Im having is that I can't be sure when Java actually decides to display it.</p>
  <p>I even made a code to actually delay after Canvas constructor, but what happens is that it is displayed AFTER the delay has expired.</p>
  <pre><code>canvas3d = new Canvas3d();
  System.err.println(&quot;Before sleep&quot;);
  try
  {
     Thread.sleep(3000);
  }
  catch (Exception e) {}
  System.err.println(&quot;After sleep&quot;);
  canvas3d.Init();
  </code></pre>
  <p>This is odd, because the drawing and rendering of elements should be handled by a completely separate thread, and my main thread sleeping should theoretically give it enough time to process the stuff. But it still waits for some reason.
  Adding Repaint() or revalidate() doesn't help.</p>
  <p>The problem with this is that sometimes, the canvas gets displayed before the Init() gets to the point that it needs it to be visible. But other times - it doesn't get displayed before that.</p>
  <p>Can I somehow FORCE the application to display the element before I'm doing anything else? Or can I somehow retrieve if the canvas is displayed at the moment or not? Because checking Canvas.visible is pointless - whether it's true or false, it doesn't mean that it's actually displayed or hidden in that precise moment during runtime. It's just a flag showing that it's supposed to be displayed, but oh, oopsie, Java just can't guarantee that it actually is!</p>