Example usage for java.awt EventQueue invokeLater

List of usage examples for java.awt EventQueue invokeLater

Introduction

In this page you can find the example usage for java.awt EventQueue invokeLater.

Prototype

public static void invokeLater(Runnable runnable) 

Source Link

Document

Causes runnable to have its run method called in the #isDispatchThread dispatch thread of Toolkit#getSystemEventQueue the system EventQueue .

Usage

From source file:org.opendatakit.briefcase.ui.MainFormUploaderWindow.java

/**
 * Launch the application.//from   ww w  . j  a va 2 s .  c o  m
 */
public static void main(String[] args) {

    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                // Set System L&F
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

                MainFormUploaderWindow window = new MainFormUploaderWindow();
                window.frame.setTitle(FORM_UPLOADER_VERSION);
                ImageIcon icon = new ImageIcon(
                        MainFormUploaderWindow.class.getClassLoader().getResource("odk_logo.png"));
                window.frame.setIconImage(icon.getImage());
                window.frame.setVisible(true);
            } catch (Exception e) {
                log.error("failed to launch app", e);
            }
        }
    });
}

From source file:org.openpnp.Main.java

public static void main(String[] args) {
    // http://developer.apple.com/library/mac/#documentation/Java/Conceptual/Java14Development/07-NativePlatformIntegration/NativePlatformIntegration.html#//apple_ref/doc/uid/TP40001909-212952-TPXREF134
    System.setProperty("apple.laf.useScreenMenuBar", "true");
    try {//ww  w  .j  a va 2 s  .c o  m
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
        throw new Error(e);
    }

    File configurationDirectory = new File(System.getProperty("user.home"));
    configurationDirectory = new File(configurationDirectory, ".openpnp");

    // If the log4j.properties is not in the configuration directory, copy
    // the default over.
    File log4jConfigurationFile = new File(configurationDirectory, "log4j.properties");
    if (!log4jConfigurationFile.exists()) {
        try {
            FileUtils.copyURLToFile(ClassLoader.getSystemResource("log4j.properties"), log4jConfigurationFile);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    // Use the local configuration if it exists.
    if (log4jConfigurationFile.exists()) {
        System.setProperty("log4j.configuration", log4jConfigurationFile.toURI().toString());
    }

    // We don't create a logger until log4j has been configured or it tries
    // to configure itself.
    logger = LoggerFactory.getLogger(Main.class);

    logger.debug(String.format("OpenPnP %s Started.", Main.getVersion()));

    Configuration.initialize(configurationDirectory);
    final Configuration configuration = Configuration.get();
    final JobProcessor jobProcessor = new JobProcessor(configuration);
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                MainFrame frame = new MainFrame(configuration, jobProcessor);
                frame.setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}

From source file:com.googlecode.vfsjfilechooser2.demo.Main.java

/**
 * Entry point//  w  w w .j  a  v  a 2s  .  com
 * @param args the command line arguments
 */
public static void main(String[] args) throws Exception {
    // show the window in the event dispatching thread
    EventQueue.invokeLater(new Main());
}

From source file:DefaultsDisplay.java

public static void main(String[] args) {

    EventQueue.invokeLater(new Runnable() {
        public void run() {
            JFrame frame = new JFrame("UIDefaults Display");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.add(new DefaultsDisplay());
            frame.pack();//from  www . j a va2  s.  c o m
            frame.setVisible(true);
        }
    });
}

From source file:com.boxupp.init.Boxupp.java

public static void main(String[] args) throws Exception {
    System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.Log4JLogger");
    SLF4JBridgeHandler.removeHandlersForRootLogger();
    SLF4JBridgeHandler.install();//from  w w  w. j  a  va  2s.c  o m

    Utilities.getInstance().createRequiredFoldersIfNotExists();
    ToolConfigurationReader toolConfig = new ToolConfigurationReader();
    Config conf = toolConfig.getConfiguration();
    AppContextBuilder appContextBuilder = new AppContextBuilder();
    DBConnectionManager connectionManager = DBConnectionManager.getInstance();
    if (connectionManager != null) {
        connectionManager.checkForProviderEntries();
    }

    String jettyPort = conf.getSetting().getPortNumber();

    final JettyServer jettyServer;
    jettyServer = (jettyPort != null) ? new JettyServer(Integer.parseInt(jettyPort)) : new JettyServer();

    HandlerCollection contexts = new HandlerCollection();

    HandlerList list = new HandlerList();
    WebSocketHandler wsHandler = new WebSocketHandler() {
        @Override
        public void configure(WebSocketServletFactory webSocketServletFactory) {
            webSocketServletFactory.register(VagrantConsole.class);
        }
    };
    ContextHandler handler = new ContextHandler();
    handler.setHandler(wsHandler);
    handler.setContextPath("/vagrantConsole/");

    list.setHandlers(new Handler[] { appContextBuilder.getStaticResourceHandler(),
            appContextBuilder.getWebAppHandler(), wsHandler });

    contexts.setHandlers(new Handler[] { list });

    jettyServer.setHandler(contexts);
    Runnable runner = new Runnable() {
        @Override
        public void run() {
            try {
                jettyServer.start();
            } catch (Exception e) {
            }
        }
    };
    EventQueue.invokeLater(runner);
    System.out.println("Boxupp Server is up at \"http://localhost:" + jettyPort);
}

From source file:org.opendatakit.briefcase.ui.CharsetConverterDialog.java

/**
 * Launch the application./*  ww  w. ja va2 s .  co  m*/
 */
public static void main(String[] args) {

    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                // Set System L&F
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

                CharsetConverterDialog window = new CharsetConverterDialog(new JFrame());
                window.setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}

From source file:App.java

/**
 * Launch the application./*w w  w  .  java 2 s  .  c o m*/
 */
public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                App window = new App();
                window.frame.setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}

From source file:fr.eurecom.hybris.demogui.HybrisDemoGui.java

public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                new HybrisDemoGui();
            } catch (Exception e) {
                e.printStackTrace();//ww w .  j  a v  a 2 s.c om
            }
        }
    });
}

From source file:AppSpringLayout.java

/**
 * Launch the application.//from   ww  w  . j ava2s .  c  o m
 */
public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                AppSpringLayout window = new AppSpringLayout();
                window.frame.setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}

From source file:com.adobe.aem.demo.gui.AemDemo.java

public static void main(String[] args) {

    String demoMachineRootFolder = null;

    // Command line options for this tool
    Options options = new Options();
    options.addOption("f", true, "Path to Demo Machine root folder");
    CommandLineParser parser = new BasicParser();
    try {//from  ww w.j a  va 2  s  .c o m
        CommandLine cmd = parser.parse(options, args);
        if (cmd.hasOption("f")) {
            demoMachineRootFolder = cmd.getOptionValue("f");
        }

    } catch (ParseException ex) {

        logger.error(ex.getMessage());

    }

    // Let's check if we have a valid build.xml file to work with...
    String buildFilePath = (demoMachineRootFolder != null ? demoMachineRootFolder
            : System.getProperty("user.dir")) + File.separator + "build.xml";
    logger.debug("Trying to load build file from " + buildFilePath);
    buildFile = new File(buildFilePath);
    if (buildFile.exists() && !buildFile.isDirectory()) {

        // Launching the main window
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {

                    UIManager.getLookAndFeelDefaults().put("defaultFont", new Font("Arial", Font.BOLD, 14));
                    AemDemo window = new AemDemo();
                    window.frameMain.setVisible(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

    } else {

        logger.error("No valid build.xml file to work with");
        System.exit(-1);

    }
}