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:havocx42.Program.java

public static void main(String[] args) throws ParseException {
    try {// w  w w .j ava  2  s  . c om
        initRootLogger();
    } catch (SecurityException | IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
        return;
    }
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
            | UnsupportedLookAndFeelException e1) {
        LOGGER.log(Level.WARNING, "Unable to set Look and Feel", e1);
    }

    Options options = new Options();
    options.addOption("nogui", false,
            "run as a command line tool, must also supply -target and -source arguments");
    options.addOption("source", true, "source directory where the PR weapons folder has been extracted");
    options.addOption("target", true, "target file to write to");
    options.addOption("version", false, "print the version information and exit");
    options.addOption("help", false, "print this message");
    CommandLineParser parser = new PosixParser();
    CommandLine cmd = parser.parse(options, args);

    if (cmd.hasOption("version")) {
        System.out.println("PRStats " + VERSION);
        System.out.println("Written by havocx42");
        return;
    }

    if ((cmd.hasOption("nogui") && (!cmd.hasOption("source") || !cmd.hasOption("target")))
            || cmd.hasOption("help")) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("PRStats", options);
        return;
    }

    final String target;
    final String source;

    source = cmd.getOptionValue("source");
    target = cmd.getOptionValue("target");
    LOGGER.info("Source Argument: " + source);
    LOGGER.info("Target Argument: " + target);

    if (!cmd.hasOption("nogui")) {
        EventQueue.invokeLater(new Runnable() {
            @SuppressWarnings("unused")
            public void run() {
                try {
                    Gui window = new Gui(source, target);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
        return;
    }

    File targetFile = new File(target);
    File sourceFile = new File(source);
    Controller controller = new Controller();
    controller.run(sourceFile, targetFile);

}

From source file:SplashScreenTest.java

public static void main(String args[]) {
    init1();/*from   www  . j a  v a  2s . c  om*/

    EventQueue.invokeLater(new Runnable() {
        public void run() {
            init2();
        }
    });
}

From source file:org.sonar.scanner.protocol.viewer.ScannerReportViewerApp.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() {
        @Override
        public void run() {
            try {
                ScannerReportViewerApp window = new ScannerReportViewerApp();
                window.frame.setVisible(true);

                window.loadReport();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

    });
}

From source file:me.philnate.textmanager.windows.MainWindow.java

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

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

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

    if (args.length == 0) {

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

                    MainBriefcaseWindow window = new MainBriefcaseWindow();
                    window.frame.setTitle(BRIEFCASE_VERSION);
                    ImageIcon icon = new ImageIcon(
                            MainBriefcaseWindow.class.getClassLoader().getResource("odk_logo.png"));
                    window.frame.setIconImage(icon.getImage());
                    window.frame.setVisible(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    } else {
        Options options = addOptions();
        CommandLineParser parser = new BasicParser();
        CommandLine cmd = null;

        try {
            cmd = parser.parse(options, args);
        } catch (ParseException e1) {
            log.error("Launch Failed: " + e1.getMessage());
            showHelp(options);
            System.exit(1);
        }

        if (cmd.hasOption(HELP)) {
            showHelp(options);
            System.exit(1);
        }

        if (cmd.hasOption(VERSION)) {
            showVersion();
            System.exit(1);
        }

        // required for all operations
        if (!cmd.hasOption(FORM_ID) || !cmd.hasOption(STORAGE_DIRECTORY)) {
            log.error(FORM_ID + " and " + STORAGE_DIRECTORY + " are required");
            showHelp(options);
            System.exit(1);
        }

        // pull from collect or aggregate, not both
        if (cmd.hasOption(ODK_DIR) && cmd.hasOption(AGGREGATE_URL)) {
            log.error("Can only have one of " + ODK_DIR + " or " + AGGREGATE_URL);
            showHelp(options);
            System.exit(1);
        }

        // pull from aggregate
        if (cmd.hasOption(AGGREGATE_URL) && (!(cmd.hasOption(ODK_USERNAME) && cmd.hasOption(ODK_PASSWORD)))) {
            log.error(ODK_USERNAME + " and " + ODK_PASSWORD + " required when " + AGGREGATE_URL
                    + " is specified");
            showHelp(options);
            System.exit(1);
        }

        // export files
        if (cmd.hasOption(EXPORT_DIRECTORY) && !cmd.hasOption(EXPORT_FILENAME)
                || !cmd.hasOption(EXPORT_DIRECTORY) && cmd.hasOption(EXPORT_FILENAME)) {
            log.error(EXPORT_DIRECTORY + " and " + EXPORT_FILENAME + " are both required to export");
            showHelp(options);
            System.exit(1);
        }

        if (cmd.hasOption(EXPORT_END_DATE)) {
            if (!testDateFormat(cmd.getOptionValue(EXPORT_END_DATE))) {
                log.error("Invalid date format in " + EXPORT_END_DATE);
                showHelp(options);
                System.exit(1);
            }
        }
        if (cmd.hasOption(EXPORT_START_DATE)) {
            if (!testDateFormat(cmd.getOptionValue(EXPORT_START_DATE))) {
                log.error("Invalid date format in " + EXPORT_START_DATE);
                showHelp(options);
                System.exit(1);
            }
        }

        BriefcaseCLI bcli = new BriefcaseCLI(cmd);
        bcli.run();
    }
}

From source file:com.ln.gui.Main.java

public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                createandshowgui();//  www .  j av  a2  s .c o m
            } catch (Exception e) {
                //Kill&print on errors
                e.printStackTrace();
                JOptionPane.showMessageDialog(null, e.getStackTrace(), "Error", JOptionPane.WARNING_MESSAGE);
            }
        }
    });
}

From source file:nl.detoren.ijsco.ui.Mainscreen.java

/**
 * Launch the application.//from w  w  w  .  jav a 2s .  c  om
 */
public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                Mainscreen window = new Mainscreen();
                window.setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}

From source file:edu.snu.leader.discrete.simulator.SimulatorLauncherGUI.java

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

From source file:com.googlecode.libautocaptcha.tools.VodafoneItalyTool.java

public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                VodafoneItalyTool window = new VodafoneItalyTool();
                window.frame.setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();//from   w  w  w.  j  a  v a2  s . c  o m
            }
        }
    });
}

From source file:task5.Histogram.java

public static void main(String[] args) {
    Histogram h = new Histogram();
    h.getImage();//from w  w  w .j a  v a2 s .co  m
    EventQueue.invokeLater(() -> {
        h.display();
    });
}