Jimit Tank
Jimit Tank

Reputation: 1549

Swing Application Run In Web Browser

I Have Create a One Swing Application and I Want To Run My Swing Application In To My Local Web Browser So Plz Tell Me How Can I Do This Because For Applet Program There Is No Any Longer Process For This.

Upvotes: 0

Views: 2940

Answers (1)

AlexR
AlexR

Reputation: 115328

Browsers do not know to run applications. They run applets.

There are 2 ways to refactor you application.

  1. if you wish the application to run in its own window, just write applet that calls YourApplication.main() from its method start()

  2. If you wish to see your application into the browser's window (as a part of your web page) you have to create applet (that extends Pannel), set its layout to BorderLayout and then put the main panel of your application into center of applet. That's it.

If you do not have one panel that contains all elements, e.g. you are adding all elements directly to JFrame you have to fix your application. Create one main panel, add all elements there and put this panel to the center of your JFrame.

Upvotes: 1

Related Questions