简体   繁体   中英

jFrame to jApplet

I have a program that uses a JFrame . I would like to make it so people could play my game from a website. Is there an easy way to turn JFrames into JApplets?

I have a program that uses a jFrame. I would like to make it so people could play my game from a website. ..

Launch the JFrame directly off a web site using Java Web Start . JWS offers many neat features, like auto-update & desktop integration (menu items, desktop shortcut).

..Is there an easy way to turn jFrames into jApplets?

When it comes to applets, nothing is easy.

It is always a matter of dealing with how different (versions of different) browsers, on different (versions of different) OS, using different (versions of different) Java plug-ins interact with each other. And that can often be summed up as 'poorly'.

I think the best way is to code your application to be contained within a JPanel. Then in the main method create the JFrame and adds that JPanel to it. Likewise, you can create a JApplet that gets created and just add the JPanel. This way your Swing application will be generally agnostic with regards to the top-level container .

You can simply create a JFrame from the applet. This JFrame then is a new OS window, and not still embedded in your browser.

Our program shows an example of this (of both popping up an external JFrame (or JDialog) and having components inside the applet, actually). (No source available, though.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM