0

I'd like to say that i'm new to Java, so any help is greatly appreciated! So I've created the following code, it's nothing important just something simple:

package helloWorldApPlet;

import java.applet.Applet;
import java.awt.Graphics;

public class HelloWorld extends Applet {
    public void paint(Graphics g) {
        g.drawString("Hello world!", 50, 25);
    }
}

And i've also created the HTML file in the same folder:

<HTML>
<HEAD>
<TITLE> A Simple Program </TITLE>
</HEAD>
<BODY>

Here is the output of my program:
<APPLET CODE="HelloWorld.class" WIDTH=150 HEIGHT=25>
</APPLET>
</BODY>
</HTML>

When I run it from the bin folder, the "Here is the output of my program" is displayed, but the applet is blocked by Java security. Adding it to the exceptions list in the Java Security panel doesnt do anything.

Thanks, Sam

Sam
  • 1,234
  • 3
  • 17
  • 32
  • Chrome looks set to remove a plug-in that will allow a variety of plug-ins to load. Java is one of them. (So I would not bother trying to support Chrome.) – Andrew Thompson Apr 11 '15 at 10:36
  • 1) Why code an applet? If it is due to the teacher specifying it, please refer them to [Why CS teachers should **stop** teaching Java applets](http://programmers.blogoverflow.com/2013/05/why-cs-teachers-should-stop-teaching-java-applets/). 2) Why use AWT? See [this answer](http://stackoverflow.com/questions/6255106/java-gui-listeners-without-awt/6255978#6255978) for many good reasons to abandon AWT using components in favor of Swing. – Andrew Thompson Apr 11 '15 at 10:36
  • My reason for this is trying to learn java through a book, which tells me a lot about creating an applet, but not about how to apply it. .ie. run it in a browser or embed it in a webpage. The book only uses AWT, however I will look into swing. I have since picked up a more updated which I hope will be more helpful. – Sam Apr 11 '15 at 20:27
  • 1
    *"I have since picked up a more updated which I hope will be more helpful"* Go with that book. The first one is hopelessly out of date. Completely skip the parts about applets. – Andrew Thompson Apr 11 '15 at 20:33

0 Answers0