Does anyone know why my Java applet does not display anything?
This is my first Java applet so I am new to creating one. I researched this problem and haven't found an answer specific to the current problem.
import java.applet.Applet;
import java.awt.Graphics;
import java.awt.Font;
import java.awt.Color;
public class JavaRocksApplet extends Applet
{
public void paint( Graphics screen )
{
Font f = new Font( "TimesRoman", Font.ITALIC, 36 );
screen.setFont( f );
Color c = new Color( 40, 80, 120 );
screen.setColor( c );
screen.drawString( "Java Rocks!!", 100, 60 );
}
}
It doesn't matter whether I use appletviewer in the command module or an html page.
<html>
<head>
<title>JavaRocksApplet</title>
</head>
<body>
<applet code = "JavaRocksApplet.class" width = 400 height = 200> </applet>
</body>
</html>
There are no errors when compiling the Java program, so I am a little bit confused about why it doesn't work.
Also, I am using a MacBook Pro running OSX 10.8.2 Mountain Lion with Java SE 6