Example usage for java.lang Runnable Runnable

List of usage examples for java.lang Runnable Runnable

Introduction

In this page you can find the example usage for java.lang Runnable Runnable.

Prototype

Runnable

Source Link

Usage

From source file:inc.cygnus.app.MainSpring.java

public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                // Implementasi Konfigurasi Spring framework
                @SuppressWarnings("resource")
                ApplicationContext appContext = new ClassPathXmlApplicationContext("applicationContext.xml");

                // Initialize service
                setCustomerService((CustomerService) appContext.getBean("customerService"));
                setProductService((ProductService) appContext.getBean("productService"));
                setPurchaseService((PurchaseService) appContext.getBean("purchaseService"));

                try {
                    // After finish service initialize
                    // Show Form Menu Master
                    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                } catch (ClassNotFoundException ex) {
                    Logger.getLogger(MainSpring.class.getName()).log(Level.SEVERE, null, ex);
                } catch (InstantiationException ex) {
                    Logger.getLogger(MainSpring.class.getName()).log(Level.SEVERE, null, ex);
                } catch (IllegalAccessException ex) {
                    Logger.getLogger(MainSpring.class.getName()).log(Level.SEVERE, null, ex);
                } catch (UnsupportedLookAndFeelException ex) {
                    Logger.getLogger(MainSpring.class.getName()).log(Level.SEVERE, null, ex);
                }/* w  w w .ja v a 2 s.  c  om*/
                Menu mmv = new Menu();

                mmv.setVisible(true);

            } catch (BeansException e) {
                e.printStackTrace();
            }
        }
    });
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    URL url = new URL("http://www.java2s.com/style/download.png");
    final BufferedImage trans = getTransparentImage(ImageIO.read(url), Color.BLACK);
    Runnable r = new Runnable() {
        @Override// w w w  .  ja v a 2 s .  c om
        public void run() {
            JLabel gui = new JLabel(new ImageIcon(trans));
            JOptionPane.showMessageDialog(null, gui);
        }
    };
    SwingUtilities.invokeLater(r);
}

From source file:org.eclipse.swt.snippets.Snippet16.java

public static void main(String[] args) {
    final Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setText("Snippet 16");
    final int time = 500;
    Runnable timer = new Runnable() {
        @Override/*from w ww.j  a va 2 s.co  m*/
        public void run() {
            if (shell.isDisposed())
                return;
            Point point = display.getCursorLocation();
            Rectangle rect = shell.getBounds();
            if (rect.contains(point)) {
                System.out.println("In");
            } else {
                System.out.println("Out");
            }
            display.timerExec(time, this);
        }
    };
    display.timerExec(time, timer);
    shell.setSize(200, 200);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:Main.java

public static void main(String args[]) throws Exception {
    final ByteArrayOutputStream out = new ByteArrayOutputStream();
    float sampleRate = 8000;
    int sampleSizeInBits = 8;
    int channels = 1;
    boolean signed = true;
    boolean bigEndian = true;
    final AudioFormat format = new AudioFormat(sampleRate, sampleSizeInBits, channels, signed, bigEndian);
    DataLine.Info info = new DataLine.Info(TargetDataLine.class, format);
    final TargetDataLine line = (TargetDataLine) AudioSystem.getLine(info);
    line.open(format);// w w  w. ja v  a2  s . c  o  m
    line.start();
    Runnable runner = new Runnable() {
        int bufferSize = (int) format.getSampleRate() * format.getFrameSize();

        byte buffer[] = new byte[bufferSize];

        public void run() {
            try {

                int count = line.read(buffer, 0, buffer.length);
                if (count > 0) {
                    out.write(buffer, 0, count);
                }

                out.close();
            } catch (IOException e) {
                System.err.println("I/O problems: " + e);
                System.exit(-1);
            }
        }
    };
    Thread captureThread = new Thread(runner);
    captureThread.start();

    byte audio[] = out.toByteArray();
    InputStream input = new ByteArrayInputStream(audio);
    final SourceDataLine line1 = (SourceDataLine) AudioSystem.getLine(info);
    final AudioInputStream ais = new AudioInputStream(input, format, audio.length / format.getFrameSize());
    line1.open(format);
    line1.start();

    runner = new Runnable() {
        int bufferSize = (int) format.getSampleRate() * format.getFrameSize();

        byte buffer[] = new byte[bufferSize];

        public void run() {
            try {
                int count;
                while ((count = ais.read(buffer, 0, buffer.length)) != -1) {
                    if (count > 0) {
                        line1.write(buffer, 0, count);
                    }
                }
                line1.drain();
                line1.close();
            } catch (IOException e) {
                System.err.println("I/O problems: " + e);
                System.exit(-3);
            }
        }
    };
    Thread playThread = new Thread(runner);
    playThread.start();

}

From source file:org.excalibur.overlay.hierarchical.grouping.MemberMain.java

public static void main(String[] args) throws Exception {
    JChannel channel = new JChannel(ClassUtils.getDefaultClassLoader().getResourceAsStream("rest_ping.xml"));
    Group group = new Group(channel);
    channel.connect("exca");

    new Thread(new Runnable() {
        @Override//from w  w w  . j a v a  2 s.c o m
        public void run() {
            while (true)
                ;
        }
    }).start();
}

From source file:br.com.etec.Main.java

@SuppressWarnings("ALL")
public static void main(String args[]) {
    Locale.setDefault(new Locale("pt", "BR"));

    SwingUtilities.invokeLater(new Runnable() {
        @Override// www  .  j  av a  2 s .  c om
        public void run() {
            try {
                // Define o look and feel.
                initLookAndFeel();
                installSmartLookAndFeel();
            } catch (Exception ex) {
                LOGGER.log(Level.WARN, null, ex);
            } finally {
                new ClassPathXmlApplicationContext("META-INF/spring-config.xml");
            }

        }
    });

}

From source file:Main.java

public static void main(String[] args) throws Exception {
    URL url = new URL("http://www.java2s.com/style/download.png");
    final BufferedImage bi = ImageIO.read(url);
    SwingUtilities.invokeLater(new Runnable() {
        @Override/* ww  w . ja  va 2  s  .  com*/
        public void run() {
            int strokeWidth = 12;
            int pad = 50;
            Shape shape = new Rectangle(pad, pad, bi.getWidth() - (2 * pad), bi.getHeight() - (2 * pad));
            Image i = getStrokedImage(bi, shape, strokeWidth);
            JOptionPane.showMessageDialog(null, new JLabel(new ImageIcon(i)));
        }
    });
}

From source file:ButtonTest.java

public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            ButtonFrame frame = new ButtonFrame();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setVisible(true);//from   w  w w  .  ja  va  2  s  . co  m
        }
    });
}

From source file:DrawTest.java

public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            DrawFrame frame = new DrawFrame();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setVisible(true);/*from   www . j  a va  2s. c o m*/
        }
    });
}

From source file:FillTest.java

public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            FillFrame frame = new FillFrame();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setVisible(true);/*from w  ww.  j a  v  a2  s.  co m*/
        }
    });
}