Convert JApplet To Frame


When instantiating a new JDialog, they can be a hassle if the parent container is a JApplet since the JDialog class only takes an AWT container class as its parent. While you can just null, there may be instances where you need to supply a value and with that, you will have to convert the JApplet into a Frame.

The way to convert a JApplet to a Frame is by using the getAncestorOfClass() method of the SwingUtilities class. Check the code:

1
(Frame) SwingUtilities.getAncestorOfClass(Frame.class, myJAppletClassVariable)

Found this post useful? Buy me a cup of coffee or help support the sponsors on the right.

Related Posts with Thumbnails