Home > Back-end >  Java applet in the small program uninitialized
Java applet in the small program uninitialized

Time:09-27

Package cn. Itcast. Day04. Homework;

import javax.swing.*;
. Import the Java applet. The applet;
import java.awt.*;

Public class text extends JApplet {
Public void init () {
JTextArea outputArea=new JTextArea (2, 20);
The Container c=getContentPane ();
C.a. dd (outputArea);
OutputArea. SetText (
"The square of The integer is 7" + square (7) +
"\ nThe Square of double 7.5 is" + Square (7.5));

}
Public int square (int x) {
Return (x * x);
}
Public double square (double y) {
Return * y y;
}
}
This is the source code

This is the HTML file
& lt; html>
& lt; The applet code="test. Class" width=800 height=600 & gt;
& lt;/applet>
& lt;/html>



Small program can open, but shows an uninitialized applet
Can't find the test shown in the CMD. Java
HTML documents and Java are together
Why don't show come out?

If I put in the code package that line to delete, can run normally,
Why is this?

CodePudding user response:

text class you wrote is this what you call is test watch carefully

CodePudding user response:

reference 1st floor usecf response:
text class you wrote is this what you call is test


. When I write the problem out didn't notice the
Actually change right after, small program also shows an uninitialized

CodePudding user response:

Are you the name of the class text or test

CodePudding user response:

reference usecf reply: 3/f
your class name is the text or the test

The class name is the text
I've said in the second floor, I write the problem out, too impatient.actually, didn't notice that I write in the HTML and the name of the class is not the same problems
But actually correct, small program is also an uninitialized

CodePudding user response:

I tried your code didn't you say mistake, I'm using the eclipse

CodePudding user response:

reference 5 floor usecf reply:
I tried your code didn't you say mistake, I'm using the eclipse

You have a code package path
As long as I put my code in the first row of package deleted, can display properly
  • Related