...

View Full Version : Help me plz, my mind is disintegrating!



Inusevs
02-22-2007, 12:07 AM
I'm currently just trying to get the js/applet connection to work. I am pretty green on programming but after I got one method to return a number from the applet to the js I thought it no big deal. The syntax didn't seem, and doesn't seem, difficult to me. However either there is a green little goblin in there somewhere or I've totally lost it.

Basically I have this one method addToCount() that works, not perfectly, once it generated a strange exception, but 99% of the time if I call oApplet with addToCount(); I get a return value that is displayed properly in an alert message. Whatever other function I try however, even if I only replace that same call ie. oApplet.addToCount() for oApplet.addBah() does absolutely nothing. The button becomes completely silent.

Hopefully someone can tell me how stupid I've been or I'm at the risk of pulling my hair out by the roots. It's just not enough code to be causing trouble, could there be something wrong with my machine?



in the body------------------------------------------
<object type="application/x-java-applet"
code="Omg.class" id="ExampleApplet">
</object>
<input type="button" value="ok" onclick="sendAndRecieve()" />
-----------------------------------------------------

When I do this it doesn't work!
The js file--------------------------------------------
function sendAndRecieve(){
var oApplet = document.getElementById("ExampleApplet");
var iAppletReturnValue = oApplet.addBah();

alert("the applet says: " + iAppletReturnValue);
}
-----------------------------------------------------

Only this method works, and that is whatever I try to exchange it for...
The js file--------------------------------------------
function sendAndRecieve(){
var oApplet = document.getElementById("ExampleApplet");
var iAppletReturnValue = oApplet.addToCount();

alert("the applet says: " + iAppletReturnValue);
}
-----------------------------------------------------

The applet-------------------------------------------

import javax.swing.JApplet;

public class Omg extends JApplet {
private int tickMe = 10;

public void init(){}

public int addBah(){
int x = 1;
return x;
}

public int addToCount(){
tickMe++;
return tickMe;
}

}
-------------------------------------------------------

nikkiH
02-22-2007, 09:42 PM
I don't suppose you wrote the first method, tested it, then wrote the second and tried testing that?

My guess: clear your .class file from the cache. It's using the old version from before you added the second method.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum