0

This is my applet. It works perfectly. It displays everything in the applet.

import java.applet.Applet;   // Imports the Applet class
import java.awt.Graphics;    // Imports the Graphics class, used to draw lines, circles, squares, text, etc

/** 
* The HelloWorldApplet class implements an applet that simply displays "Hello World!". 
*/ 

// Our HelloWorldApplet class extends  the Applet class, giving it access to all the methods of Applet.
public class HelloWorldApplet extends Applet
{         

// The paint method draws anything that is in our applet on the applet screen.  
// It takes a graphics object (g), that is used to draw

public void paint(Graphics screen) 
{     
    // drawString is a method of the Graphics class.  It takes a string, and two integer parameters 
    // as x and y coordinates.  These coordinates correspond to Quadrant I of a traditional coordinate
    // plane, so they are always positive.         
    screen.drawString("Hello World Applet", 50, 30);
    screen.drawString("Sikki Nixx", 50, 60);
    screen.drawString("What was yesterday's date?", 50, 90);
    screen.drawString(printAmerican(), 50, 120);
}

public String printAmerican() {
    return ("Thursday" + ", " + "October" + " " + 15 + ", " + 2015 + ".");
}
}

And this is what I have for my HTML, but nothing shows up on the webpage. Can anyone help me figure this out?

<HTML>
<BODY>
<APPLET CODE=HelloWorldApplet.class WIDTH=200 HEIGHT=100>
</APPLET>
</BODY>
</HTML>
Sikki Nixx
  • 51
  • 4
  • Is Java enabled in the browser, and is the code url correct? – NickJ Oct 16 '15 at 14:19
  • Possible duplicate of [Java - Applet simply not displaying?](http://stackoverflow.com/questions/8440840/java-applet-simply-not-displaying) – Mage Xy Oct 16 '15 at 14:24
  • 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 Oct 17 '15 at 15:04

0 Answers0