aspose file tools*
The moose likes Applets and the fly likes It runs on appletviewer but not on applet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "It runs on appletviewer but not on applet" Watch "It runs on appletviewer but not on applet" New topic
Author

It runs on appletviewer but not on applet

Brian Snyder
Ranch Hand

Joined: Feb 03, 2001
Posts: 142
I created a simple calculator and it runs nicely on appletviewer, but for the last few days, I can not figure out why it doesn't function on my web page.
Here's my code and you'll find the HTML below it and a link to the page it can be seen. Thanks in advance!!!


The HTML

The web page:
http://snydb2001.freeservers.com/Calc.htm
Patrick Lentz
Greenhorn

Joined: Oct 04, 2000
Posts: 23
Bryan,
I have no idea right now, but I do have a question for you. Since some time I have been noticing how nicely some people can put sample code onhere. I am wondering which editor you guys are using? I'm also asking this because if I try to copy and paste the code in TextPad 4 to try things out, all characters will be put directly after eachother and I have to spend time on rearranging the code nicely.
Thanks!
Patrick
Stephanie Grasson
Ranch Hand

Joined: Jun 14, 2000
Posts: 347
Patrick,
It is not a question of which editor Brian is using but how he posted his code. He used UBB tags to maintain the nice formatting. You can learn how to use UBB tags here:
http://www.magictraders.com/ubb/ubbcode.html
In particular, look at the Code Tag section.
Hope this helps.
Stephanie
Angela Lamb
Ranch Hand

Joined: Feb 22, 2001
Posts: 156
If you look at the Java console in your browser, you'll see that it throws a NoSuchMethodException for the parseDouble method. That is because parseDouble has only been around since version 1.2 and most browsers only support 1.1 (unless they have the JRE plugin). It's a good rule of thumb to remember that 90% of the time, if your applet works in appletviewer but not in a browser, this is the reason.
Stephanie Grasson
Ranch Hand

Joined: Jun 14, 2000
Posts: 347
Hi Brian,
You might also want to take another look through your code. It does run in AppletViewer, but does not function properly. For example, I tried
1 + 3 =
and got the answer as 6.
Stephanie
Brian Snyder
Ranch Hand

Joined: Feb 03, 2001
Posts: 142
Thanks Steph and Angela.
What would you recommend rather than parseDouble?
If I do 1 + 3 a couple of times, one time or no times after start up I get 6 some of the time, but 4 most of the time. How can that be? I can't find the bug.
Thanks all for the help!!!
Zahid, Butt
Ranch Hand

Joined: Feb 16, 2001
Posts: 100
Hi ALL
I have a qiuck simple question, How do you run an applet in appletviewer through DOS ??
I have JDK 1.3 on windows 98.
Thanks in advance.
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Brian,
You are having an off by one problem because your oper[] array has a 0 element, but you only start adding data to it at location 1... so when you call it the first time you need to make it access element 1, change this code ( in actionPerformed(), inside the last if statement, after you assign m to the oper[] array... ) -
Change from :

To:

Zahid,
You run appletviewer in DOS with the command :

Where somePage.html is a html file that contains the applet tag that calls the applet you want to run. Of course, appletviewer is in the jdk1.3/bin directory, so that directory will have to be in your path for the appletviewer command to work.
HTH,
-Nate


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Angela Lamb
Ranch Hand

Joined: Feb 22, 2001
Posts: 156
Instead of parseDouble:
double num = (Double.valueOf(stringVal)).doubleValue();
[This message has been edited by Angela Ann (edited March 23, 2001).]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: It runs on appletviewer but not on applet