List of usage examples for java.lang Runnable Runnable
Runnable
From source file:MainGUI.java
public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override/*from w w w .j a va2 s . com*/ public void run() { MainGUI gui = new MainGUI(""); gui.setVisible(true); } }); }
From source file:clienteescritorio.Grafica.java
/** * @param args the command line arguments *//*ww w.j av a 2 s .c o m*/ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(Grafica.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(Grafica.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(Grafica.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(Grafica.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { //new Grafica().setVisible(true); } }); }
From source file:GUI.PlotHere.java
/** * @param args the command line arguments *//* ww w .j a va 2 s. c om*/ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(PlotHere.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(PlotHere.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(PlotHere.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(PlotHere.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new PlotHere("").setVisible(true); } }); }
From source file:net.bluehornreader.service.ServiceManager.java
public static void main(String[] args) throws Exception { String webappPath = null;//from w w w.ja v a 2 s. c o m if (Utils.isInJar()) { if (args.length != 1 || isHelp(args)) { System.err.println("Usage:\njava -Dlog4j.configuration=file:<PATH>/log4j.properties " + "-jar bluehorn-reader-<VERSION>.one-jar.jar <PATH>/config.properties"); System.exit(1); } } else { if ((args.length != 2 && args.length != 1) || isHelp(args)) { System.err.println("Usage:\njava -Dlog4j.configuration=file:<PATH>/log4j.properties " + "net.bluehornreader.service.ServiceManager <PATH>/config.properties <PATH>/webapp"); System.exit(1); } if (args.length == 2) { webappPath = args[1]; } else { URL url = ServiceManager.class.getClassLoader() .getResource("net/bluehornreader/model/Article.class"); if (url != null) { webappPath = url.getPath().replace("target/classes/net/bluehornreader/model/Article.class", "") + "src/main/webapp"; if (new File(webappPath).isDirectory()) { LOG.info("Found webapp folder at " + webappPath); } else { webappPath = null; } } if (webappPath == null) { System.err.println( "Cannot locate the webapp folder. You'll have to specify it manually, as the second parameter."); System.exit(1); } } } if (webappPath == null) { webappPath = new File(".").getCanonicalPath(); // just to have a valid folder to pass } String configFileName = args[0]; Config.setup(configFileName); final ServiceManager serviceManager = new ServiceManager(webappPath); Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { @Override public void run() { LOG.info("***************************************************************************\n\n"); LOG.info("Shutting down ServiceManager ..."); serviceManager.shutdown(); } })); }
From source file:gtu._work.etc.EnglishTester.java
/** * Auto-generated main method to display this JFrame *///from ww w. j a v a2s . c o m 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 v a 2s . com*/ * * @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:br.com.criativasoft.opendevice.samples.ui.SimpleChart.java
public static void main(final String[] args) { EventQueue.invokeLater(new Runnable() { @Override/*from www .j ava 2 s . co 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.// ww w . j av a2s. co 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:menusearch.ui.MenuGraph.java
/** * @param args the command line arguments *///from w w w .j a va2s . com public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(MenuGraph.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(MenuGraph.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(MenuGraph.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(MenuGraph.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new MenuGraph().setVisible(true); } }); }
From source file:com.weibo.wesync.client.NHttpClient2.java
public static void main(String[] args) throws Exception { RSAPublicKey publicKey = RSAEncrypt.loadPublicKey("D:\\weibo\\meyou_gw\\conf\\public.pem"); // /*from w w w . j ava2 s. co m*/ byte[] cipher = RSAEncrypt.encrypt(publicKey, password.getBytes()); password = RSAEncrypt.toHexString(cipher); // HTTP parameters for the client HttpParams params = new SyncBasicHttpParams(); params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 30000) .setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 30000) .setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024) .setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true); // Create HTTP protocol processing chain HttpProcessor httpproc = new ImmutableHttpProcessor(new HttpRequestInterceptor[] { // Use standard client-side protocol interceptors new RequestContent(), new RequestTargetHost(), new RequestConnControl(), new RequestUserAgent(), new RequestExpectContinue() }); // Create client-side HTTP protocol handler HttpAsyncRequestExecutor protocolHandler = new HttpAsyncRequestExecutor(); // Create client-side I/O event dispatch final IOEventDispatch ioEventDispatch = new DefaultHttpClientIODispatch(protocolHandler, params); // Create client-side I/O reactor IOReactorConfig config = new IOReactorConfig(); config.setIoThreadCount(1); final ConnectingIOReactor ioReactor = new DefaultConnectingIOReactor(config); // Create HTTP connection pool BasicNIOConnPool pool = new BasicNIOConnPool(ioReactor, params); // Limit total number of connections to just two pool.setDefaultMaxPerRoute(2); pool.setMaxTotal(1); // Run the I/O reactor in a separate thread Thread t = new Thread(new Runnable() { public void run() { try { // Ready to go! ioReactor.execute(ioEventDispatch); } catch (InterruptedIOException ex) { System.err.println("Interrupted"); } catch (IOException e) { System.err.println("I/O error: " + e.getMessage()); } System.out.println("Shutdown"); } }); // Start the client thread t.start(); // Create HTTP requester // HttpAsyncRequester requester = new HttpAsyncRequester( // httpproc, new DefaultConnectionReuseStrategy(), params); // Execute HTTP GETs to the following hosts and HttpHost[] targets = new HttpHost[] { // new HttpHost("123.125.106.28", 8093, "http"), // new HttpHost("123.125.106.28", 8093, "http"), // new HttpHost("123.125.106.28", 8093, "http"), // new HttpHost("123.125.106.28", 8093, "http"), // new HttpHost("123.125.106.28", 8093, "http"), // new HttpHost("123.125.106.28", 8093, "http"), // new HttpHost("123.125.106.28", 8093, "http"), // new HttpHost("123.125.106.28", 8093, "http"), // new HttpHost("123.125.106.28", 8093, "http"), // new HttpHost("123.125.106.28", 8093, "http"), // new HttpHost("123.125.106.28", 8093, "http"), new HttpHost("123.125.106.28", 8082, "http") }; final CountDownLatch latch = new CountDownLatch(targets.length); int callbackId = 0; for (int i = 0; i < 1; i++) { for (final HttpHost target : targets) { BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/wesync"); // String usrpwd = Base64.encodeBase64String((username + ":" + password).getBytes()); // request.setHeader("authorization", "Basic " + usrpwd); request.setHeader("uid", "2565640713"); Meyou.MeyouPacket packet = null; if (callbackId == 0) { packet = Meyou.MeyouPacket.newBuilder().setCallbackId(String.valueOf(callbackId++)) .setSort(MeyouSort.notice).build(); } else { packet = Meyou.MeyouPacket.newBuilder().setCallbackId(String.valueOf(callbackId++)) .setSort(MeyouSort.wesync).build(); } ByteArrayEntity entity = new ByteArrayEntity(packet.toByteArray()); request.setEntity(entity); // BasicHttpRequest request = new BasicHttpRequest("GET", "/test.html"); System.out.println("send ..."); HttpAsyncRequester requester = new HttpAsyncRequester(httpproc, new DefaultConnectionReuseStrategy(), params); requester.execute(new BasicAsyncRequestProducer(target, request), new BasicAsyncResponseConsumer(), pool, new BasicHttpContext(), // Handle HTTP response from a callback new FutureCallback<HttpResponse>() { public void completed(final HttpResponse response) { StatusLine status = response.getStatusLine(); int code = status.getStatusCode(); if (code == 200) { try { latch.countDown(); DataInputStream in; in = new DataInputStream(response.getEntity().getContent()); int packetLength = in.readInt(); int start = 0; while (packetLength > 0) { ByteArrayOutputStream outstream = new ByteArrayOutputStream( packetLength); byte[] buffer = new byte[1024]; int len = 0; while (start < packetLength && (len = in.read(buffer, start, packetLength)) > 0) { outstream.write(buffer, 0, len); start += len; } Meyou.MeyouPacket packet0 = Meyou.MeyouPacket .parseFrom(outstream.toByteArray()); System.out.println(target + "->" + packet0); if ((len = in.read(buffer, start, 4)) > 0) { packetLength = Util.readPacketLength(buffer); } else { break; } } } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else { System.out.println("error code=" + code + "|" + status.getReasonPhrase()); } } public void failed(final Exception ex) { latch.countDown(); System.out.println(target + "->" + ex); } public void cancelled() { latch.countDown(); System.out.println(target + " cancelled"); } }); Thread.sleep((long) (Math.random() * 10000)); } } // latch.await(); // System.out.println("Shutting down I/O reactor"); // ioReactor.shutdown(); // System.out.println("Done"); }