How To Use JApplet As Parent Of JDialog

To set a JDialog to modal and attach it to a parent window, a parameter has to be passed as JFrame. However, suppose you show a JDialog from a JApplet? Casting it to JFrame will result in an Exception.

Its other constructor parameters are either java.awt.Dialog or java.awt.Window which, from a Swing standpoint should not be mixed with heavyweight components.

Luckily, with JDK 1.6 the SwingUtilities class has a method that can return the window component for any component that you pass as the parameter.

Related Posts Plugin for WordPress, Blogger...

Leave a Reply

Your email address will not be published. Required fields are marked *