text not appearing in applet
the following program compiles and runs but the text does not appear in the applet after appletviewer command,
import java.awt.Container;
import java.swing.*;
public class SquareInt extends JApplet {
public void init() {
String output = " ";
JTextArea outputArea = new JTextArea (10, 20);
Container c = getContentPane();
c.add(outputArea);
int result;
for (int x = 0; x <= 10; x++) {
result = square(x);
output += "The square of " + x + "is " + result + "\n";
}
outputArea .setText(output);
}
public int square(int y) {
return y * y;
}
}
// Square.html
<HTML>
<HEAD>
<TITLE> This is a simple program </TITLE>
</HEAD>
<BODY>
Here is the output of my program:
<APPLET CODE = "SquareInt.class" WIDTH = 60 HEIGHT = 40 >
</APPLET>
</BODY>
</HTML>
"C How To Program" 3rd edit., Deitel & Deitel, page 896 & 897