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!!!
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
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
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.
Joined: Jun 14, 2000
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
Joined: Feb 03, 2001
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!!!
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 :
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
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Joined: Feb 22, 2001
Instead of parseDouble: double num = (Double.valueOf(stringVal)).doubleValue(); [This message has been edited by Angela Ann (edited March 23, 2001).]
subject: It runs on appletviewer but not on applet