Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Applet is not responding???

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi All
I'm trying to run a script when the applet gets downloded,or at least to get respond when i click on it.I can't make that works. here is my html file and java file:
Html file:
//==============
<html>
<body>
<script language=&quot;javascript&quot; >
function show()
{
var y=88;
document.writeln(&quot;hello world &quot;);
return y;

}

</script>

<object code=&quot;TextFieldApplet10.class&quot; id=&quot;tom&quot; width=&quot;500&quot; height=&quot;200&quot; onLoad=&quot;show();&quot; >
</object>
<input type=&quot;button&quot; value=&quot;Click on me &quot; onClick=&quot;alert('Hee hee!');&quot;></a>
</body>
</html>
//=============
Here is the java file&quot;
//=============
import java.awt.*;
import java.applet.*;
public class TextFieldApplet10 extends Applet
{
public void init()
{
TextField txt1 = new TextField(&quot; &quot;);
add(txt1);
}
}
//=============
thanks for your time.

 
Shouldn't your <input type...> be inside a

<form>


</form> tag?

Disclaimer:
Beware: Studies have shown that research causes cancer in lab rats.
 
Hi Tom,

I tested out your codes and your applet seems fine to me. Its just that the codes for your html page is incorrect. I am not sure what you want to see in your html page but here is the codes.

Codes:
<html>
<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!--
if (navigator.userAgent.indexOf(&quot;MSIE&quot;) > 0) {
// Microsoft Internet Explorer
document.writeln('<CENTER> ');
document.writeln('<OBJECT classid=&quot;clsid:8AD9C840-044E-11D1-B3E9-00805F499D93&quot; ');
document.writeln('width=&quot;200&quot; height=&quot;200&quot; align=&quot;baseline&quot; ');
document.writeln('codebase=&quot; ');
document.writeln('<PARAM NAME=&quot;code&quot; VALUE=&quot;TextFieldApplet10.class&quot;> ');
document.writeln('<PARAM NAME=&quot;type&quot; VALUE=&quot;application/x-java-applet;version=1.2&quot;> ');
document.writeln('No JDK 1.2 support for applet! ');
document.writeln('</OBJECT> ');
document.writeln('<CENTER> ');

}
else {
// Netscape Navigator / Communicator
document.writeln('<EMBED type=&quot;application/x-java-applet;version=1.2&quot; ');
document.writeln('width=&quot;200&quot; height=&quot;200&quot; align=&quot;baseline&quot; ');
document.writeln('code=&quot;TextFieldApplet10.class&quot; ');
document.writeln('pluginspage=&quot; ');
document.writeln('<NOEMBED>No JDK 1.2 support for applet!</NOEMBED> ');
document.writeln('</EMBED>');
};
//-->

</SCRIPT>
</APPLET>
<body>
<input type=&quot;button&quot; value=&quot;Click on me &quot; onClick=&quot;alert('Heehee!');&quot;></a>
</body>
</html> If you need additional help, you can email to me at zaoliang@hotmail.com I don't guaranty that I will be able to solve your problems but I will try my best :)
 
thanks for your time
I'm trying to test the onLoad Event Handler that what i assume we can use with applet tag or Object tag.as :
<object code=&quot;TextFieldApplet10.class&quot; id=&quot;matt&quot; width=&quot;500&quot; height=&quot;200&quot; onLoad=&quot;show();&quot; >
</object>
just simply i need to click on the applet and get what ever response fro show() method.
I used it with the input tag for button and it works,but with applet tag it doesn't work for some reason.
Here is the java and html files.
//======= TextFieldApplet10.java=====
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class TextFieldApplet10 extends Applet
{
public void init()
{
TextField txt1 = new TextField(&quot; &quot;);
add(txt1);
txt1.addActionListener(new moh());
this.setBackground(Color.red);
}
}
class moh implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
System.out.println(&quot;Hello&quot;);

}
}
//======testApplet.html =====
<script language=&quot;javascript&quot; >
function show()
{
var y=88;
document.writeln(&quot;hello world today &quot;);
return y;

}
</script>

<html>
<body>
<form action=&quot;&quot; >

<object code=&quot;TextFieldApplet10.class&quot; id=&quot;matt&quot; width=&quot;500&quot; height=&quot;200&quot; onLoad=&quot;show();&quot; >
</object>
<input type=&quot;button&quot; value=&quot;Click on me &quot; onClick=&quot;show();&quot;></a>

</form>
</body>
</html>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top