I\'m writing a Swing application that needs to function either as an applet in a browser or as a standalone application, i.e. it may be contained in either a JFrame or a JApplet
Here interesting method for showing frames as modal to specified owner is described: Show the given frame as modal to the specified owner
However, start() method of class EventPump should be modified in such way:
protected void start() throws Exception
{
Class> cl = Class.forName("java.awt.Conditional");
Object conditional = Proxy.newProxyInstance(cl.getClassLoader(), new Class[] { cl }, this);
ThreadGroup threadGroup = Thread.currentThread().getThreadGroup();
String name = Thread.currentThread().getName();
EventQueue eventQueue = Toolkit.getDefaultToolkit().getSystemEventQueue();
Constructor constructor = Class.forName("java.awt.EventDispatchThread").
getDeclaredConstructor(ThreadGroup.class, name.getClass(), eventQueue.getClass());
constructor.setAccessible(true);
Object eventDispatchThread = constructor.newInstance(threadGroup, name, eventQueue);
Method pumpMethod = eventDispatchThread.getClass().getDeclaredMethod("pumpEvents", cl);
pumpMethod.setAccessible(true);
pumpMethod.invoke(eventDispatchThread, conditional);
}