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:AmazonKinesisAuditVerify.java

public static void main(String[] args) throws IOException {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                AmazonKinesisAuditVerify window = new AmazonKinesisAuditVerify();
                //window.frame.setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();// w  ww. j a  v a 2  s . c om
            }
        }
    });

    init();
    /*
            if (args.length == 1 && "delete-resources".equals(args[0])) {
    deleteResources();
    return;
            }
            
            String workerId = InetAddress.getLocalHost().getCanonicalHostName() + ":" + UUID.randomUUID();
            KinesisClientLibConfiguration kinesisClientLibConfiguration =
        new KinesisClientLibConfiguration(SAMPLE_APPLICATION_NAME,
                SAMPLE_APPLICATION_STREAM_NAME,
                credentialsProvider,
                workerId);
            kinesisClientLibConfiguration.withInitialPositionInStream(SAMPLE_APPLICATION_INITIAL_POSITION_IN_STREAM);
            
            IRecordProcessorFactory recordProcessorFactory = new AmazonKinesisApplicationRecordProcessorFactory();
            Worker worker = new Worker(recordProcessorFactory, kinesisClientLibConfiguration);
            
            System.out.printf("Running %s to process stream %s as worker %s...\n",
        SAMPLE_APPLICATION_NAME,
        SAMPLE_APPLICATION_STREAM_NAME,
        workerId);
            
            int exitCode = 0;
            try {
    worker.run();
            } catch (Throwable t) {
    System.err.println("Caught throwable while processing data.");
    t.printStackTrace();
    exitCode = 1;
            }
            System.exit(exitCode);
            */
    String propertiesFile = null;

    if (args.length > 1) {
        System.err.println("Usage: java " + AmazonKinesisAuditVerify.class.getName() + " <propertiesFile>");
        System.exit(1);
    } else if (args.length == 1) {
        propertiesFile = args[0];
    }

    configure(propertiesFile);

    System.out.println("Starting " + applicationName);
    LOG.info("Running " + applicationName + " to process stream " + streamName);

    IRecordProcessorFactory recordProcessorFactory = new AmazonKinesisAuditRecordProcessorFactory();
    Worker worker = new Worker(recordProcessorFactory, kinesisClientLibConfiguration);

    int exitCode = 0;
    try {
        worker.run();
    } catch (Throwable t) {
        LOG.error("Caught throwable while processing data.", t);
        exitCode = 1;
    }
    System.exit(exitCode);
}

From source file:com.francetelecom.rd.dashboard.pc.DashboardPC.java

/**
 * Launch the application./* ww w.j  a  v a2s .co m*/
 */
public static void main(String[] args) {
    Runtime.getRuntime().addShutdownHook(new Thread() {
        public void run() {
            try {
                logger.info("Application close, will unpublish node!");
                myNode.unPublishFromHomeBus();
            } catch (HomeBusException e) {
                logger.error("Application close, could not unpublish node : " + e.getMessage());
                e.printStackTrace();
            }
        }
    });

    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {

                DashboardPC frame = new DashboardPC();

                String nodeId = frame.getIdForType(ID_type_Node);
                frame.busFactory = new HomeBusFactory(nodeId);
                try {
                    // temporary solution
                    // fake solution
                    // must remove this sleep after sds will no longer need it
                    Thread.sleep(1000);
                } catch (Exception e) {
                    logger.error("Error while sleep before node publish! \n" + e.getMessage());
                }

                frame.initNode(nodeId);
                frame.initDashboardWithRules();

                frame.setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}

From source file:pdi.HistogramaRGB.java

public static void main(String[] args) {
    EventQueue.invokeLater(() -> {
        new HistogramaRGB().mostraTela();
    });
}

From source file:com.adobe.aem.demomachine.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 av a 2  s . c  om
        CommandLine cmd = parser.parse(options, args);
        if (cmd.hasOption("f")) {
            demoMachineRootFolder = cmd.getOptionValue("f");
        }

    } catch (ParseException ex) {

        logger.error(ex.getMessage());

    }

    // Let's grab the version number for the core Maven file
    String mavenFilePath = (demoMachineRootFolder != null ? demoMachineRootFolder
            : System.getProperty("user.dir")) + File.separator + "java" + File.separator + "core"
            + File.separator + "pom.xml";
    File mavenFile = new File(mavenFilePath);
    if (mavenFile.exists() && !mavenFile.isDirectory()) {

        try {
            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            DocumentBuilder builder = factory.newDocumentBuilder();
            Document document;
            document = builder.parse(mavenFile);
            NodeList list = document.getElementsByTagName("version");
            if (list != null && list.getLength() > 0) {
                aemDemoMachineVersion = list.item(0).getFirstChild().getNodeValue();
            }

        } catch (Exception e) {
            logger.error("Can't parse Maven pom.xml file");
        }

    }

    // 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);

    }
}

From source file:br.com.criativasoft.opendevice.samples.ui.SimpleChart.java

public static void main(final String[] args) {
    EventQueue.invokeLater(new Runnable() {
        @Override//from   w w  w . ja v a 2  s  . c o  m
        public void run() {

            StreamConnection usb = StreamConnectionFactory.createUsb("/dev/ttyACM0");
            SimpleChart demo = new SimpleChart(TITLE, usb);
            demo.pack();
            RefineryUtilities.centerFrameOnScreen(demo);
            demo.setVisible(true);
        }
    });
}

From source file:velocitekProStartAnalyzer.MainWindow.java

/**
 * Launch the application./*  w ww . ja  v  a2  s.  c o  m*/
 */
public static void main(String[] args) {
    Locale.setDefault(Locale.ENGLISH);
    EventQueue.invokeLater(new Runnable() {
        @Override
        public void run() {
            try {
                MainWindow window = new MainWindow();
                window.frame.setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
    EventQueue.invokeLater(new Runnable() {
        @Override
        public void run() {
            setStartFinishMapMarkers();
        }
    });
    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {
            defaultSize();

        }
    });
}

From source file:it.isislab.dmason.tools.batch.BatchWizard.java

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

From source file:org.fhaes.fhsamplesize.view.FHSampleSize.java

/**
 * Launch as stand-alone application./*w ww.j  av  a 2  s .  co m*/
 */
public static void main(String[] args) {

    EventQueue.invokeLater(new Runnable() {

        @Override
        public void run() {

            try {
                FHSampleSize window = new FHSampleSize(null);
                window.setVisible(true);
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
    });
}

From source file:Trabalho.HistogramaHSB.java

public static void main(String[] args) throws IOException {
    EventQueue.invokeLater(() -> {
        try {/*w w  w. j  a  v  a 2 s . c  om*/
            new HistogramaHSB().mostraTela();
        } catch (IOException ex) {
            Logger.getLogger(HistogramaHSB.class.getName()).log(Level.SEVERE, null, ex);
        }

    });
}

From source file:com.bsoft.baseframe.baseframe_utils.beanUtils.Classgenerator.java

/**
 * ??/* w  w w  .  j a  va2 s. c  o m*/
 * @param args
 */
public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
        @Override
        public void run() {
            JFrame frame = new Classgenerator();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setVisible(true);
            frame.setResizable(false);
        }
    });
}