Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Converting an Application to an Applet

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there some documentation somewhere on Converting a Java Swing Application into a Java Applet?
 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It really depends on how the application has been written and what it does. If you have a way of starting the application and getting the GUI's main panel then you can just do:

If the application does lots of background processing (ie animations) which you want to stop when the browser is hidden etc then you will also have to override the stop() and start() methods and take action accordingly.
 
Tim Alvord
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tony Docherty,
That worked pretty good inside of the Eclipse IDE. For some reason setting the background color of the Applet to black didn't work. It was displayed in Gray.

When I try and run the Applet from a browser, all I get is a blank Gray box the size of the Applet... Any ideas?
 
Tony Docherty
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

For some reason setting the background color of the Applet to black didn't work. It was displayed in Gray.


You probably should be setting the background colour of the JPanel.

When I try and run the Applet from a browser, all I get is a blank Gray box the size of the Applet... Any ideas?


Not without seeing what you are doing ie the code, html etc
 
Rancher
Posts: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This may be of interest: https://coderanch.com/how-to/java/AppletsFaq#application
 
Tim Alvord
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tony,
I am setting both the JFrame and the Pane background color to Black.

Here's what I've got:


Like I said before it works in Eclipse more or less, but not in the browser...
 
Tony Docherty
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why are you getting a new instance of the applet and adding that to the applet content pane?

You need to set the background of the highest level opaque component that provides the background for your app (probably a JPanel). I should go back to running the application as a stand-alone app and see if you can change the background colour of that.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic