Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

build applet from existing application

 
liana lim
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i already have a small application using JFrame. How to turn it into a Applet??

I already make some applet code, that code work in applet viewer but not in a browser. It say applet started, but thre's nothing just a gray box. I think My browser is ok, because it can open other applet.
Is there something wrong??? please help

Here is the applet code to call NewJFrame.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello "liana liana"-

Welcome to JavaRanch.

On your way in you may have missed that we have a policy on screen names here at JavaRanch. Basically, it must consist of a first name, a space, and a last name, and not be obviously fictitious. Since yours does not conform with it, please take a moment to change it, which you can do right here.

As to your question, applets work a bit different than applications. For starters, what you might try is to replace these two lines:

by

Assuming that NewJFrame extends JFrame, there's no need for the "a" JFrame. You also can't add a JFrame (which is a window) to the content pane of another window.

This will open a new window, though. Is that what you want? If not, then you should refactor the code to put whatever goes into NewJFrame (most likely some JComponents) to go in the content pane of the JApplet.
 
liana lim
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is there other way to make my java application run on web??
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java Web Start would be another option.
 
Norm Radder
Bartender
Posts: 1227
13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"but thre's nothing just a gray box. "
Is there anything in the browser's java console?
Copy and paste it here.
 
liana lim
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i already fix my problem.
not use jframe, i call panel from the applet and it works
thanks anyway
 
Kushagra Bindal
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[ UD: Please do not post unrelated questions into existing topics. That's called "hijacking", and is generally frowned upon. ]
[ November 13, 2008: Message edited by: Ulf Dittmer ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic