Just want to try running applet on my browser, so I made a simple program:
import java.awt.*;
import javax.swing.*;
public class NotHelloWorldApplet extends JApplet {
public void init() {
EventQueue.invokeLater(new Runnable() {
public void run() {
JLabel label = new JLabel("Hello World applet", SwingConstants.CENTER);
add(label);
}
});
}
}
And here is my HTML file:
<html>
<head>
<title> Hello World Applet</title>
</head>
<body>
<applet code=“HelloWorldApplet.class” width=“300” height=“300”>
</applet>
</body>
</html>
And here is my browser configuration:
Everything looks great, but when I run my HTML file, it doesn't work. It simply show the content:
I can view it on Eclipse, just cannot view it on the browser. Is there anything I made it wrong?
Ok, when I open the HTML file on Dreamweaver, the HTML file oddly appear lots of extra lines. I don't know why, but I made the HTML file via TextEditor in the first place, I guess it is just not a qualified "HTML editor". Therefore, I redo a HTML file on Dreamweaver, and it works. Lesson learned, don't trust TextEditor to make a HTML file, because it might have some hidden content.