From 5d619bef1ca953318e14485771cd715bf0b11d9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurent=20Gr=C3=A9goire?= Date: Thu, 2 Oct 2014 18:03:24 +0200 Subject: [PATCH] Execute Swing init code in Swing event thread. --- src/main/java/org/truffautronic/Main.java | 38 ++++++++++++++--------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/truffautronic/Main.java b/src/main/java/org/truffautronic/Main.java index d9c7cb6..bf79276 100644 --- a/src/main/java/org/truffautronic/Main.java +++ b/src/main/java/org/truffautronic/Main.java @@ -23,6 +23,7 @@ import java.io.File; import java.util.Locale; +import javax.swing.SwingUtilities; import javax.swing.UIManager; import org.truffautronic.controller.AppController; @@ -30,19 +31,28 @@ public class Main { - public static void main(String[] args) throws Exception { - - I18N.setLocale(Locale.getDefault()); - - UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); - - UIManager.put("TabbedPane.selected", Color.YELLOW); - UIManager.put("ToggleButton.select", Color.YELLOW); - - AppController appController = new AppController(); - if (args.length >= 1) { - appController.openInitialFile(new File(args[0])); - } - appController.run(); + public static void main(final String[] args) throws Exception { + + SwingUtilities.invokeLater(new Runnable() { + public void run() { + I18N.setLocale(Locale.getDefault()); + + try { + UIManager.setLookAndFeel(UIManager + .getSystemLookAndFeelClassName()); + } catch (Exception e) { + throw new RuntimeException(e); + } + + UIManager.put("TabbedPane.selected", Color.YELLOW); + UIManager.put("ToggleButton.select", Color.YELLOW); + + AppController appController = new AppController(); + if (args.length >= 1) { + appController.openInitialFile(new File(args[0])); + } + appController.run(); + } + }); } }