Java EventQueue .invokeAndWait (Runnable runnable)

Syntax

EventQueue.invokeAndWait(Runnable runnable) has the following syntax.

public static void invokeAndWait(Runnable runnable)    throws InterruptedException ,     InvocationTargetException

Example

In the following code shows how to use EventQueue.invokeAndWait(Runnable runnable) method.


/*from w  w  w  .java2  s  .c  o  m*/
import java.awt.EventQueue;

import javax.swing.JFrame;

public class Main {
   public static void main(String[] args)
   {
      EventQueue.invokeLater(new Runnable()
         {
            public void run()
            {
               JFrame frame = new ImageProcessingFrame();
               frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
               frame.setVisible(true);
            }
         });
   }
}

class ImageProcessingFrame extends JFrame
{
   public ImageProcessingFrame()
   {
      setTitle("ImageProcessingTest");
      setSize(200, 200);
   }

}




















Home »
  Java Tutorial »
    java.awt »




BasicStroke
BorderLayout
CardLayout
Color
Cursor
Desktop
DesktopManager
DisplayMode
EventQueue
FlowLayout
FocusTraversalPolicy
Font
FontMetrics
GradientPaint
Graphics
Graphics2D
GraphicsConfiguration
GraphicsDevice
GraphicsEnvironment
GridBagConstraints
GridBagLayout
GridLayout
Image
ItemSelectable
KeyboardFocusManager
LayoutManager
LayoutManager2
Point
Rectangle
Robot
Shape
SplashScreen
SystemColor
SystemTray
TexturePaint
TrayIcon
Toolkit
Transparency