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

public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            creatGUI();//from w ww  .  j  a  va 2  s .c o  m
        }
    });
}

From source file:Main.java

public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            Main mainForm = new Main();
            mainForm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            mainForm.setSize(250, 250);//from  www . ja v  a2s .com

            Cursor cursor = new Cursor(Cursor.HAND_CURSOR);
            mainForm.setCursor(cursor);

            mainForm.pack();
            mainForm.setVisible(true);
        }
    });
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    final JTextField textfield = new JTextField(10);

    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            textfield.requestFocus();/*from   w  ww. ja v a2 s.  c  o m*/
        }
    });
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    final JTextField textfield = new JTextField(10);

    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            textfield.requestFocus();//from  w ww  .  j  av  a 2  s . com
        }
    });

}

From source file:Main.java

public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
        @Override/* ww w .  j av  a2s . com*/
        public void run() {
            JFrame frame = new JFrame();
            frame.add(new ImagePanel());

            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setSize(400, 400);
            frame.setVisible(true);
        }
    });
}

From source file:Main.java

public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            final Date date = new Date();
            final JLabel timeLabel = new JLabel(date.toString());
            Timer timer = new Timer(1000, new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    date.setTime(System.currentTimeMillis());
                    timeLabel.setText(date.toString());
                }//ww  w.  ja  va  2  s .c om
            });
            timer.start();
            JOptionPane.showMessageDialog(null, timeLabel);
        }
    });
}

From source file:Main.java

public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
        @Override//  ww  w  .  j  av a2  s  . co m
        public void run() {
            JFrame frame = new JFrame();
            frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
            Panel panel = new Panel();
            frame.setContentPane(panel);
            frame.pack();
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
        }
    });
}

From source file:Main.java

public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            JFrame frame = new JFrame();
            frame.add(new TestImage());
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.pack();/*from w ww .  ja v a 2  s  . c om*/
            frame.setVisible(true);
        }
    });
}

From source file:Main.java

public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
        @Override//from  ww  w. j a  v  a  2 s  .co  m
        public void run() {
            new FormattedTextFieldExample();
        }
    });
}

From source file:Main.java

public static void main(String args[]) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            try {
                JFrame f = new JFrame();
                f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

                BufferedImage image = ImageIO.read(new URL("http://www.java2s.com/style/download.png"));
                f.getContentPane().add(new JLabel(new ImageIcon(dye(image, new Color(255, 0, 0, 128)))));
                f.pack();/*from   w ww .  j a v a2  s .c o m*/
                f.setVisible(true);

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

}