asplus
Instructor
- Oct 11, 2002
- 16
I am trying to test an applet with a thread and I get the message indicated in the subject above when I run it on my PC. I have a class file for the java source that matches in name. My html is simply running the applet giving it a with and height for the window. Everything is in the same subdirectory.
I have uploaded my class file to my web site. When I run it with IE, I just get the blank grey area. When I run it with Netscape, I get a blank grey area plus an error message: java.lang.ClassFormat Error Bad major version number.
If you want to check out my website, go to main page. On the top right hand side is the applet space. It should display a scrolling message but nothing happens. This used to work fine until I changed to a new PC with Windows XP and downloaded JDK version 1.4.0.
Here is the code of the applet followed by the html to test locally.
import java.awt.*;
public class PSABanner extends java.applet.Applet implements Runnable {
Thread runner;
int yPos = 220;
int yMove = -4;
Font f = new Font("TimesRoman", Font.BOLD, 12);
public void start() {
if (runner == null) {
runner = new Thread(this);
runner.start();
}
}
public void stop() {
runner = null;
}
public void run() {
Thread thisThread = Thread.currentThread();
while (runner == thisThread) {
yPos += yMove;
if (yPos < 0)
yPos = 220;
repaint();
try {
Thread.sleep(10);
}
catch (InterruptedException e) {
}
}
}
public void paint(Graphics screen) {
// Draw background
screen.setFont(f);
screen.setColor(Color.blue);
screen.drawString("SUMMER REGISTRATION", 72, yPos);
screen.drawString("Saturday, March 9th 2002", 78, yPos + 20);
screen.drawString("2:00 P.M. TO 6:00 P.M.", 87, yPos + 40);
screen.drawString("and", 134, yPos + 60);
screen.drawString("Saturday, March 23rd 2002", 78, yPos + 80);
screen.drawString("2:00 P.M. TO 6:00 P.M.", 87, yPos + 100);
screen.drawString("Riverdale High School", 90, yPos +120);
screen.drawString("5060 Blvd Des Sources, Pierrefonds", 61, yPos + 140);
screen.drawString("or BY MAIL", 107, yPos + 160);
screen.drawString("Administrator/Registrar", 82, yPos + 180);
screen.drawString("4600 Des Cageux", 94, yPos + 200);
screen.drawString("Pierrefonds, Québec", 91, yPos + 220);
screen.drawString("H9J 3R4", 118, yPos + 240);
screen.drawString("REGISTRATION FEES", 88, yPos + 260);
screen.drawString("$85.00 per child", 100, yPos + 280);
screen.drawString("4th child and more FREE", 75, yPos + 300);
screen.drawString("Additional fees for Intercity and Senior", 48, yPos + 320);
screen.drawString("NO REFUND", 101, yPos + 340);
screen.drawString("COST AFTER APRIL 1st $110", 65, yPos + 360);
screen.drawString("FOR MORE INFORMATION", 66, yPos + 380);
screen.drawString("INFO-SOCCER 696-2505", 80, yPos +400);
}
}
HTML:
<applet code="PSABanner.class" height=200 width=300>
</applet>
Any help would really be appreciated, I am really stucked...
I have uploaded my class file to my web site. When I run it with IE, I just get the blank grey area. When I run it with Netscape, I get a blank grey area plus an error message: java.lang.ClassFormat Error Bad major version number.
If you want to check out my website, go to main page. On the top right hand side is the applet space. It should display a scrolling message but nothing happens. This used to work fine until I changed to a new PC with Windows XP and downloaded JDK version 1.4.0.
Here is the code of the applet followed by the html to test locally.
import java.awt.*;
public class PSABanner extends java.applet.Applet implements Runnable {
Thread runner;
int yPos = 220;
int yMove = -4;
Font f = new Font("TimesRoman", Font.BOLD, 12);
public void start() {
if (runner == null) {
runner = new Thread(this);
runner.start();
}
}
public void stop() {
runner = null;
}
public void run() {
Thread thisThread = Thread.currentThread();
while (runner == thisThread) {
yPos += yMove;
if (yPos < 0)
yPos = 220;
repaint();
try {
Thread.sleep(10);
}
catch (InterruptedException e) {
}
}
}
public void paint(Graphics screen) {
// Draw background
screen.setFont(f);
screen.setColor(Color.blue);
screen.drawString("SUMMER REGISTRATION", 72, yPos);
screen.drawString("Saturday, March 9th 2002", 78, yPos + 20);
screen.drawString("2:00 P.M. TO 6:00 P.M.", 87, yPos + 40);
screen.drawString("and", 134, yPos + 60);
screen.drawString("Saturday, March 23rd 2002", 78, yPos + 80);
screen.drawString("2:00 P.M. TO 6:00 P.M.", 87, yPos + 100);
screen.drawString("Riverdale High School", 90, yPos +120);
screen.drawString("5060 Blvd Des Sources, Pierrefonds", 61, yPos + 140);
screen.drawString("or BY MAIL", 107, yPos + 160);
screen.drawString("Administrator/Registrar", 82, yPos + 180);
screen.drawString("4600 Des Cageux", 94, yPos + 200);
screen.drawString("Pierrefonds, Québec", 91, yPos + 220);
screen.drawString("H9J 3R4", 118, yPos + 240);
screen.drawString("REGISTRATION FEES", 88, yPos + 260);
screen.drawString("$85.00 per child", 100, yPos + 280);
screen.drawString("4th child and more FREE", 75, yPos + 300);
screen.drawString("Additional fees for Intercity and Senior", 48, yPos + 320);
screen.drawString("NO REFUND", 101, yPos + 340);
screen.drawString("COST AFTER APRIL 1st $110", 65, yPos + 360);
screen.drawString("FOR MORE INFORMATION", 66, yPos + 380);
screen.drawString("INFO-SOCCER 696-2505", 80, yPos +400);
}
}
HTML:
<applet code="PSABanner.class" height=200 width=300>
</applet>
Any help would really be appreciated, I am really stucked...