Accessing Applets from within JavaScript : Applet Jar : Development JAVASCRIPT DHTML TUTORIALS


JAVASCRIPT DHTML TUTORIALS » Development » Applet Jar »

 

Accessing Applets from within JavaScript



//java source file
import java.applet.*;
import java.awt.*;

public class FancyText extends Applet {
 String text="I like Java!";


 public void paint(Graphics g) {
  g.drawString(text,30,30);
 }
 
 public void setText(String s) {
  text=s;
  repaint();
 }
}

//Loading and Accessing an Applet 
<head>
<TITLE>Accessing Applets</TITLE>
<SCRIPT LANGUAGE="JavaScript"><!--
function accessApplet() {
 setTimeout("changeText('I like JavaScript!')",2000)
 setTimeout("changeText('I like JavaScript and Java!')",4000)
 setTimeout("changeText('I like Java!')",6000)
 setTimeout("accessApplet()",8000)
}
function changeText(s) {
 window.document.fancyText.setText(s)
}
// --></SCRIPT>
</HEAD>
<BODY onLoad="accessApplet()">
<APPLET CODE="FancyText.class" NAME="fancyText"
 WIDTH=450 HEIGHT=150>
[The FancyText Applet]
</APPLET>



           
       



-

Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

JAVASCRIPT DHTML TUTORIALS

 Navioo Development
» Applet Jar