== Why is this an issue?

Swing interfaces should be constructed and shown from the Swing event dispatch thread. Doing so from any other thread, such as from ``++main++`` risks deadlocks since you run the risk of multiple threads accessing things which are inherently not thread-safe.


Instead, use ``++SwingUtilities.invokeLater++`` or ``++SwingUtilities.invokeAndWait++`` to kick off a ``++new Runnable++`` that handles your GUI creation.


=== Noncompliant code example

[source,java]
----
public static void main(String args[]) {
  makeGui(); // Noncompliant
}

public void makeGui() {
  JFrame frame = new JFrame();
  // ...
  frame.show();
}
----


=== Compliant solution

[source,java]
----
public static void main(String args[]) {
  SwingUtilities.invokeAndWait(new Runnable() {
    public void run() {
      makeGui();
    }
  }
}

public void makeGui() {
  JFrame frame = new JFrame();
  // ...
  frame.show();
}
----


ifdef::env-github,rspecator-view[]

'''
== Implementation Specification
(visible only on this page)

=== Message

Move this "xxx" call to the event dispatch thread.


endif::env-github,rspecator-view[]
