Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Converting an Application to an Applet

 
Tim Alvord
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there some documentation somewhere on Converting a Java Swing Application into a Java Applet?
 
Tony Docherty
Bartender
Posts: 2957
59
  • Mark post as helpful
  • send pies
  • 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
  • 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: 2957
59
  • Mark post as helpful
  • send pies
  • 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
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This may be of interest: https://www.coderanch.com/how-to/java/AppletsFaq#application
 
Tim Alvord
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • 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: 2957
59
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic