<p>What would be the best way to draw a simple animation just before showing a modal <a href="https://docs.oracle.com/javase/9/docs/api/javax/swing/JDialog.html" rel="nofollow noreferrer">JDialog</a>? (i.e. expanding borders from the mouse click point to the dialog location). I thought it would be possible to draw on the glasspane of the parent frame on the <code>setVisible</code> method of the dialog.</p>

<p>However, since the JDialog is modal to the parent, I couldn't find a way to pump drawing events into <a href="https://docs.oracle.com/javase/tutorial/uiswing/concurrency/dispatch.html" rel="nofollow noreferrer">EDT</a> before the JDialog becomes visible, since the current event on the EDT has not been completed yet.</p>

Are you trying to show the JDialog indepentently of the annimation? In order to get the order set properly, you may need to bundle those actions in a runnable that is passed to the EDT at once.
eg:
```
```
SwingUtilities.invokeLater(new Runnable(){
   public void run(){
      doAnnimation();
      showDialog();
   }
}
```
```
It may be best to subclass JDialog so that you can just add the doAnnimation() logic to the setVisible(..) or show() method before calling the superclass implementation.
Finally, I imagine you'll need to set the dimensions of the dalog manually --  I don't remember if Java will know the actual size of the dialog before it is shown, so you may get some useless information for your annimation if you query the size before showing it.