synchronized (f)
JPanel modalInterceptor = new JPanel(); modalInterceptor.setOpaque(false); JLayeredPane lp = JLayeredPane.getLayeredPaneAbove(f); lp.setLayer(modalInterceptor, JLayeredPane.MODAL_LAYER.intValue()); modalInterceptor.setBounds(0, 0, lp.getWidth(), lp.getHeight()); modalInterceptor.addMouseListener(new MouseAdapter(){}); modalInterceptor.addMouseMotionListener(new MouseMotionAdapter(){}); lp.add(modalInterceptor); f.toFront();    EventQueue queue = Toolkit.getDefaultToolkit().getSystemEventQueue(); try
  private static void startModal(JInternalFrame f)  {    synchronized (f)      {	final JInternalFrame tmp = f;	tmp.toFront();	f.addInternalFrameListener(new InternalFrameAdapter()	    {	      public void internalFrameClosed(InternalFrameEvent e)	      {		synchronized (tmp)		  {		    tmp.removeInternalFrameListener(this);		    tmp.notifyAll();		  }	      }	    });	try	  {	    while (! f.isClosed())	      f.wait();	  }	catch (InterruptedException ignored)	  {          // Ignore this Exception.	  }      }  }