Example usage for javax.swing SwingUtilities invokeLater

List of usage examples for javax.swing SwingUtilities invokeLater

Introduction

In this page you can find the example usage for javax.swing SwingUtilities invokeLater.

Prototype

public static void invokeLater(Runnable doRun) 

Source Link

Document

Causes doRun.run() to be executed asynchronously on the AWT event dispatching thread.

Usage

From source file:de.mfo.jsurf.Main.java

/**
 * @param args//from ww w  . ja  va2  s .co  m
 */
public static void main(String[] args) {

    String jsurf_filename = "";
    Options options = new Options();

    options.addOption("s", "size", true, "width (and height) of a image (default: " + size + ")");
    options.addOption("q", "quality", true,
            "quality of the rendering: 0 (low), 1 (medium, default), 2 (high), 3 (extreme)");
    options.addOption("o", "output", true,
            "output PNG into this file (- means standard output. Use ./- to denote a file literally named -.)");

    CommandLineParser parser = new PosixParser();
    HelpFormatter formatter = new HelpFormatter();
    String cmd_line_syntax = "jsurf [options] jsurf_file";
    String help_header = "jsurf is a renderer for algebraic surfaces. If - is specified as a filename the jsurf file is read from standard input. "
            + "Use ./- to denote a file literally named -.";
    String help_footer = "";
    try {
        CommandLine cmd = parser.parse(options, args);

        if (cmd.getArgs().length > 0)
            jsurf_filename = cmd.getArgs()[0];
        else {
            formatter.printHelp(cmd_line_syntax, help_header, options, help_footer);
            return;
        }

        if (cmd.hasOption("output")) {
        }

        if (cmd.hasOption("size"))
            size = Integer.parseInt(cmd.getOptionValue("size"));

        int quality = 1;
        if (cmd.hasOption("quality"))
            quality = Integer.parseInt(cmd.getOptionValue("quality"));
        switch (quality) {
        case 0:
            aam = AntiAliasingMode.ADAPTIVE_SUPERSAMPLING;
            aap = AntiAliasingPattern.OG_1x1;
            break;
        case 2:
            aam = AntiAliasingMode.ADAPTIVE_SUPERSAMPLING;
            aap = AntiAliasingPattern.OG_4x4;
            break;
        case 3:
            aam = AntiAliasingMode.SUPERSAMPLING;
            aap = AntiAliasingPattern.OG_4x4;
            break;
        case 1:
            aam = AntiAliasingMode.ADAPTIVE_SUPERSAMPLING;
            aap = AntiAliasingPattern.QUINCUNX;
        }
    } catch (ParseException exp) {
        System.out.println("Unexpected exception:" + exp.getMessage());
        System.exit(-1);
    } catch (NumberFormatException nfe) {
        formatter.printHelp(cmd_line_syntax, help_header, options, help_footer);
        System.exit(-1);
    }

    final Properties jsurf = new Properties();
    try {
        if (jsurf_filename.equals("-"))
            jsurf.load(System.in);
        else
            jsurf.load(new FileReader(jsurf_filename));
        FileFormat.load(jsurf, asr);
    } catch (Exception e) {
        System.err.println("Unable to read jsurf file " + jsurf_filename);
        e.printStackTrace();
        System.exit(-2);
    }

    asr.setAntiAliasingMode(aam);
    asr.setAntiAliasingPattern(aap);

    // display the image in a window 
    final String window_title = "jsurf: " + jsurf_filename;
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            JFrame f = new JFrame(window_title);
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            JSurferRenderPanel p = null;
            try {
                p = new JSurferRenderPanel(jsurf);
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            f.setContentPane(p);

            //                f.getContentPane().add( new JLabel( new ImageIcon( window_image ) ) );
            f.pack();
            //                f.setResizable( false );
            f.setVisible(true);
        }
    });
}

From source file:gtu._work.ui.DirectoryCompareUI.java

/**
 * Auto-generated main method to display this JFrame
 *//*w ww  .  ja v  a  2s  .  c o m*/
public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            DirectoryCompareUI inst = new DirectoryCompareUI();
            inst.setLocationRelativeTo(null);
            gtu.swing.util.JFrameUtil.setVisible(true, inst);
        }
    });
    System.out.println("done...");
}

From source file:MainGUI.java

public static void main(String[] args) {

    SwingUtilities.invokeLater(new Runnable() {
        @Override/* w  w w . j av a2 s.co m*/
        public void run() {
            MainGUI gui = new MainGUI("");
            gui.setVisible(true);
        }
    });
}

From source file:gtu._work.etc.EnglishTester.java

/**
 * Auto-generated main method to display this JFrame
 */// w  ww. j  ava 2 s  .  com
public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            EnglishTester inst = new EnglishTester();
            //                inst.setLocationRelativeTo(null);
            JCommonUtil.setLocationToRightBottomCorner(inst);
            gtu.swing.util.JFrameUtil.setVisible(true, inst);
        }
    });
}

From source file:com.jsystem.j2autoit.AutoItAgent.java

/**
 * Launch the server side/*w  w  w.  j  a  va  2  s. c o  m*/
 * 
 * @param args
 */
public static void main(String[] args) {
    try {
        Log.initLog();
        isDebug = AutoItProperties.DEBUG_MODE_KEY.getValue(isDebug);
        isAutoDeleteFiles = AutoItProperties.AUTO_DELETE_TEMPORARY_SCRIPT_FILE_KEY.getValue(isAutoDeleteFiles);
        if (isAutoDeleteFiles) {
            Integer tempHistory = AutoItProperties.AUTO_IT_SCRIPT_HISTORY_SIZE_KEY
                    .getValue(DEFAULT_HistorySize);

            HistoryFile.init();
            HistoryFile.setHistory_Size(tempHistory);
        }
        isForceAutoItShutDown = AutoItProperties.FORCE_AUTO_IT_PROCESS_SHUTDOWN_KEY
                .getValue(isForceAutoItShutDown);
        webServicePort = AutoItProperties.AGENT_PORT_KEY.getValue(webServicePort);
        serverState = AutoItProperties.SERVER_UP_ON_INIT_KEY.getValue(serverState);

        Log.setLogMode(false, isDebug);
        Runtime.getRuntime().addShutdownHook(new ExitThread());
        Log.info(System.getProperty("user.dir") + NEW_LINE);
        Log.info("AutoIt Location: " + getAutoExecuterItLocation("Unable to find") + NEW_LINE);
        startAutoItWebServer(webServicePort);
        if (serverState) {
            serverState = false;
            runWebServer();
        }

        UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");

    } catch (Exception exception) {
        Log.throwable(exception.getMessage() + NEW_LINE, exception);
    }

    /* Turn off metal's use of bold fonts */
    UIManager.put("swing.boldMetal", Boolean.FALSE);
    //Schedule a job for the event-dispatching thread:
    //adding TrayIcon.
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            createAndShowGUI();
        }
    });
}

From source file:ntpgraphic.LineChart.java

public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
        @Override//from  www . j a v  a  2s.c o m
        public void run() {
            new LineChart().setVisible(true);
        }
    });
}

From source file:com.game.ui.views.MapEditor.java

public static void main(String[] args) throws Exception {
    GameBean.doInit();//from  ww  w  .j  a v  a2s. c o m
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            try {
                new MapEditor();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
    });
}

From source file:postenergy.PostEnergy.java

/**
 * @param args the command line arguments
 *//*ww  w. ja v a 2 s.  c o m*/
public static void main(String[] args) {
    // TODO code application logic here
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            PostEnergy ex = new PostEnergy();
            ex.setVisible(true);
        }
    });
}

From source file:BlendCompositeDemo.java

public static void main(String... args) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            new BlendCompositeDemo().setVisible(true);
        }//ww w. j a  v  a 2s . c o  m
    });
}

From source file:gtu._work.ui.ExecuteOpener.java

/**
 * Auto-generated main method to display this JFrame
 *///from w ww  . j  a va  2  s  .co  m
public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            ExecuteOpener inst = new ExecuteOpener();
            inst.setLocationRelativeTo(null);
            gtu.swing.util.JFrameUtil.setVisible(true, inst);
        }
    });
}