I do not recommend trying to combine your applet code into an iframe code. They are two different functions.
Iframes are windows cut into a website page to allow you to see another web page.
You could put the applet code into a new web page called applet.htm.
Click a link on the main page.
The iframe could change content to show applet.htm web page in your iframe window.
Warning: If the applet OPENS a window, it will not stay in the iframe.