Applet driving me nuts

K

Kevin

Hi all,

I created an applet and tested it with appletviewer. All fine. Then
with html and it says class not found. After searching forums I found
out that if you use swing you need to use htmlconverter as well.
Result after htmlconverter. It does not even show the applet
shape(grey shape of 640x480). Finally I started to create an easy
applet(just a drawstring saying hello). Result stays the same
Animatie.class not found. The strangest thing is that when I run both
applets at home (with sdk1.4.2) it runs because i run applets with my
sdk. Does anyone know why this happens. I shall show both applet
codes:
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.applet.AppletContext;
import javax.swing.*;
import java.net.URL;

public class Animatie extends Applet {

Image achtergrondGebufferd, logo, afbeelding1, afbeelding2,
afbeelding3, welkom, bienvenue, welcome;
ImageIcon achtergrondGebufferd;
URL nederlands, frans, engels;
boolean getekend=false;

public void init() {
try {
nederlands = new URL("http://www.orca-nv.be/nl/index.html");
frans = new URL("http://www.orca-nv.be/fr/index.html");
engels = new URL("http://www.orca-nv.be/en/index.html");
}
catch (Exception e) {
System.out.print(e);
}
achtergrond = getImage(getDocumentBase(),
"afbeelding/achtergrond.jpg");
achtergrondGebufferd = new ImageIcon(achtergrond);
logo = getImage(getDocumentBase(), "afbeelding/logo.jpg");
afbeelding1 = getImage(getDocumentBase(),
"afbeelding/Afbeelding1.jpg");
afbeelding2 = getImage(getDocumentBase(),
"afbeelding/Afbeelding2.jpg");
afbeelding3 = getImage(getDocumentBase(),
"afbeelding/Afbeelding3.jpg");
welkom = getImage(getDocumentBase(), "afbeelding/welkom.gif");
bienvenue = getImage(getDocumentBase(),
"afbeelding/bienvenue.gif");
welcome = getImage(getDocumentBase(), "afbeelding/welcome.gif");
}

public void paint(Graphics g) {
if (getekend) {
achtergrondGebufferd.paintIcon(this, g, 0, 0);
g.drawImage(logo, 220, 190, 200, 100, this);
g.drawImage(afbeelding1, 218, 326, 205, 154, this);
g.drawImage(afbeelding2, 0, 190, 205, 154, this);
g.drawImage(afbeelding3, 435, 190, 205, 154, this);
g.drawImage(welkom, 100, 80, 420, 80, this);
g.drawImage(bienvenue, 10, 10, 210, 40, this);
g.drawImage(welcome, 420, 10, 210, 40, this);
addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent me) {
if (me.getX() >= 100 && me.getX() <= 520 && me.getY() >= 80 &&
me.getY() <= 160)
getAppletContext().showDocument(nederlands);
if (me.getX() >= 10 && me.getX() <= 220 && me.getY() >= 10 &&
me.getY() <= 50)
getAppletContext().showDocument(frans);
if (me.getX() >= 420 && me.getX() <= 630 && me.getY() >= 10 &&
me.getY() <= 50)
getAppletContext().showDocument(engels);
}
public void mouseReleased(MouseEvent me) {
}
public void mouseClicked(MouseEvent me) {
}
});
}
else {
achtergrondGebufferd.paintIcon(this, g, 0, 0);
getekend = true;
int j = 100;
for (int i=0; i<100;i+=2) {
g.drawImage(logo, 270-i/2, 240-i/2, j+i, i, this);
try {
Thread.sleep(20);
}
catch (Exception e) {
}
}
for (int i=0; i<180;i+=2) {
g.drawImage(logo, 220, 190, 200, 100, this);
g.drawImage(afbeelding1, 218, 506-i, 205, 154, this);
try {
Thread.sleep(20);
}
catch (Exception e) {
}
}
for (int i=0; i<205;i+=2) {
g.drawImage(logo, 220, 190, 200, 100, this);
g.drawImage(afbeelding1, 218, 531-i, 205, 154, this);
g.drawImage(afbeelding2, -205+i, 190, 205, 154, this);
g.drawImage(afbeelding3, 640-i, 190, 205, 154, this);
try {
Thread.sleep(20);
}
catch (Exception e) {
}
}
g.drawImage(welkom, 100, 80, 420, 80, this);
g.drawImage(bienvenue, 10, 10, 210, 40, this);
g.drawImage(welcome, 420, 10, 210, 40, this);
addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent me) {
if (me.getX() >= 100 && me.getX() <= 520 && me.getY() >= 80 &&
me.getY() <= 160)
getAppletContext().showDocument(nederlands);
if (me.getX() >= 10 && me.getX() <= 220 && me.getY() >= 10 &&
me.getY() <= 50)
getAppletContext().showDocument(frans);
if (me.getX() >= 420 && me.getX() <= 630 && me.getY() >= 10 &&
me.getY() <= 50)
getAppletContext().showDocument(engels);
}
public void mouseReleased(MouseEvent me) {
}
public void mouseClicked(MouseEvent me) {
}
});
}
}

}
//END OF CODE ANIMATIE.JAVA

import java.awt.*;
import java.applet.*;

public class Animatie extends Applet {

public void paint(Graphics g) {
g.drawString("HElloE",100,100);
}

}

//END OF CODE ANIMATIE.JAVA

THE HTML CODE IS (BEFORE HTMLCONVERTOR) :
<HTML>
<HEAD>
<TITLE>MyApplet Example1</TITLE>
</HEAD>
<BODY>
<H1>MyApplet</H1>
<HR>
<P>
<APPLET type="application/x-java-applet;version=1.4" Codebase="/" CODE
= "Animatie" WIDTH = "640" HEIGHT = "480">
</APPLET>
</P>
<HR>
</BODY>
</HTML>

ON the website the codebase is http://www.orca-nv.be, I also tried
with a . or just leave out codebase. None of them worked but it always
worked at home (I am not at home at the moment.)

Any help is much appreciated.
Kevin
 
A

Andrew Thompson

Kevin said:
Hi all,

I created an applet and tested it with appletviewer. All fine. Then
with html and it says class not found. After searching forums I found
out that if you use swing you need to use htmlconverter as well.
....
htmlconverter relies on JavaScript (for more complicated
examples) which adds another complication, or rather,
another technology that can be disabled by either the
user or their SysAdmin.

A better solution is the Java Version Applet..
http://www.physci.org/test/JRE/
ON the website the codebase is http://www.orca-nv.be, I also tried
with a . or just leave out codebase. None of them worked but it always
worked at home (I am not at home at the moment.)

An important part of what you did NOT mention was browser
version and OS. IE 5 acts diefferently to IE 6 which _both_
work differently to IE 5 on a Mac.

I tested your URL with IE 6 and Mozilla 1.3a on XP.

I got the applet in IE (though I have already installed
the 1.4 JRE), but saw only the three buttons, nothing else,
not even a gray square in Mozilla.

I had a look at your html. Typical coders html. ;-)

http://validator.w3.org/check?uri=http://www.orca-nv.be/&charset=iso
-8859-1+%28Western+Europe%29&doctype=HTML+4.01+Transitional

Even after forcing a doctype and charset, it showed
4 errors.

A lot of coders seem to underestimate the effects of invalid
html, but ultimately it is all the browser has to render the
final document. If the html document does not conform
to recognised standards, the browser is left to guess what
the author meant, of take the easier route and ignore the
invalid html altogether.

I recommend fixing the html before worrying about the
applet. Browsers do not seem to know how to handle
what you have at the moment. That would be best
asked over at computer.infosystems.www.authoring.html

HTH
 
K

Kevin

Hi,

First of all thank you for this information I teached a lesson :)
I changed the whole code to a w3c compliant code. The problem remains.
I also jarred the files into Animatie.jar. The result is the same.
Second I have a new problem.
If I want to check whether or not the plugin is required (the JRE
applet) I do not have any longer a w3c compliant code. Result:The
problems remains applet not found.
The test machines are winxp ie6 and win2000 ie6, at home(I work
temporarly in UK) I have a winME ie6 j2sdk1.4.2, I also tested on
another winXP ie6 machine.
I would not be bothered with people disabling the javascript because I
only use it to scroll the menubars.

PS: I won't be able to do any changes until monday.
Cheers,
Kevin
 
A

Andrew Thompson

Kevin said:

Hi..

Could I ask that you post enough of what the other person said
to give your answers a 'context' (like I am doing here, the people
reading can see what I am answering)
First of all thank you for this information I teached a lesson :)

I will presume you are speaking about the advice I gave you
to validate the page..
I changed the whole code to a w3c compliant code. The problem remains.
I also jarred the files into Animatie.jar. The result is the same.
Second I have a new problem.
If I want to check whether or not the plugin is required (the JRE
applet) I do not have any longer a w3c compliant code. Result:The
problems remains applet not found.

OK. the HTML 4.0 spec has deprecated the 'applet' tag.
In order to use it and keep the validator happy, you
need to code your 1st line of html as..
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

instead of..
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">

The 'Transitional' allows you to use tags defined in HTML 3.2,
so you might also have it as..
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">

[ But using this format you cannot use CSS ]
The test machines are winxp ie6 and win2000 ie6, at home(I work
temporarly in UK) I have a winME ie6 j2sdk1.4.2, I also tested on
another winXP ie6 machine.
I would not be bothered with people disabling the javascript because I
only use it to scroll the menubars.

No. I'd have to check again, but I am almost certain the
way you used htmlconverter, _htmlconverter_ writes the
javascript code (that I was referring to). I was not referring
to any menu bars. [ but since you mentioned it, how does a
non-js user scroll the menu bar - is the page still useable
for them? ]
 
K

Kevin

The test machines are winxp ie6 and win2000 ie6, at home(I work
temporarly in UK) I have a winME ie6 j2sdk1.4.2, I also tested on
another winXP ie6 machine.
I would not be bothered with people disabling the javascript because I
only use it to scroll the menubars.

No. I'd have to check again, but I am almost certain the
way you used htmlconverter, _htmlconverter_ writes the
javascript code (that I was referring to). I was not referring
to any menu bars. [ but since you mentioned it, how does a
non-js user scroll the menu bar - is the page still useable
for them? ]
Yes. People that have a non js compliant browser will not see the
javascript because of the <!-- and //--> tags. People that disable
javascript just see the title of the page.

The code is now fully compliant thx. I now am going to test the
applet. (Still does not work)
 
K

Kevin

I have tried multiple ways to start the applet but it always says
(java console):
Error loading class: JavaVersionApplet
java.lang.NoClassDefFoundError
java.lang.ClassNotFoundException: JavaVersionApplet
at com/ms/vm/loader/URLClassLoader.loadClass
at com/ms/vm/loader/URLClassLoader.loadClass
at com/ms/applet/AppletPanel.securedClassLoad
at com/ms/applet/AppletPanel.processSentEvent
at com/ms/applet/AppletPanel.processSentEvent
at com/ms/applet/AppletPanel.run
at java/lang/Thread.run
Error loading class: Animatie
java.lang.NoClassDefFoundError
java.lang.ClassNotFoundException: Animatie
at com/ms/vm/loader/URLClassLoader.loadClass
at com/ms/vm/loader/URLClassLoader.loadClass
at com/ms/applet/AppletPanel.securedClassLoad
at com/ms/applet/AppletPanel.processSentEvent
at com/ms/applet/AppletPanel.processSentEvent
at com/ms/applet/AppletPanel.run
at java/lang/Thread.run

This means that I probably do not have the right plugin but how can i
tell them i need the right plugin if the versionApplet won't start
from the beginning. (The last option is of course I add a link to the
plugin page)
Or do you think I implement the javaversionapplet wrong. The jars,
classes are on the main directory (same as index.html).
The java code of the versionapplet seems ms applet compliant (I mean
it doesn't use java1.2(javax.*)).

PS: If you have any programming problems feel free to mail me at
(e-mail address removed) Because I do not always look at the forums.
 
A

Andrew Thompson

Kevin said:
I have tried multiple ways to start the applet but it always says
(java console):
Error loading class: JavaVersionApplet

There is a way of specifying the Applet call so that
even Mozilla with Java disable (or IE with no JVM)
will display a message, but it did not seem that was
the problem ion tyour case.

It's time we need an URL. Where is your Applet?
 
K

Kevin

It's time we need an URL. Where is your Applet?
I have changed the jars into JavaAppletVersion.jar abd Animatie.jar
(instead of adding both to animatie.jar) But it doesn't make any
difference. I also uploaded the sourcecode of both applets.
 
A

Andrew Thompson

Kevin said:

Oops! Sorry for implying you had not given an url.

I had certainly seen your page before.
________________________________________
Ugggh! Those scrolling messages in the titles
and taskbar _have_ to go. I must have sent the
browser to 'full-screen' before they took effect,
I would just have closed the window and not helped
you at all.

They make me nauseous - sick. They are truly hideous,
and seeing them makes a good case for turning off JS.
Please, if you have any repect for your visitors at all,
remove them.

I am going over to Mozilla so I can turn off JS
and view your page without risk of projectile
vomiting.

That's better.
________________________________________

But wait, all you problems are in IE, and you mention
IE 6.. I noticed this line in the stacktrace earlier..

java.lang.ClassNotFoundException: JavaVersionApplet
at com/ms/vm/loader/URLClassLoader.loadClass

The com/ms .... bit makes me think the browser
is using the old MS VM, but I thought it never shipped
with IE 6. Can anyone else clarify?
________________________________________
The thing is, your page loads just fine here,
I see 'Welkom' at the top, 'Orca' in the middle,
and pictures slide in from the bottom, left and
right.

[ And just to clarify, that is in both IE6 and
Mozilla1.3 on XP, each running a 1.4 JVM.
I tried testing it with Java off, but the Applet
kept appearing in IE (typical) and Mozilla
displayed the message that Java was disabled
(as we intend)]

I suspect there is someething screwy with that
particular browser that you are using to view
the page, try it at the library or an internet cafe..
 
K

Kevin

They make me nauseous - sick. They are truly hideous,
and seeing them makes a good case for turning off JS.
Please, if you have any repect for your visitors at all,
remove them.
I am making this site for a friend and he wants it so I leave it on.
But wait, all you problems are in IE, and you mention
IE 6.. I noticed this line in the stacktrace earlier..

java.lang.ClassNotFoundException: JavaVersionApplet
at com/ms/vm/loader/URLClassLoader.loadClass

The com/ms .... bit makes me think the browser
is using the old MS VM, but I thought it never shipped
with IE 6. Can anyone else clarify?
________________________________________
The thing is, your page loads just fine here,
I see 'Welkom' at the top, 'Orca' in the middle,
and pictures slide in from the bottom, left and
right.
This is what I should get as well.
So it works but not on the ie6 browsers. I asked the friend to view it
and he says he can't see it either.
[ And just to clarify, that is in both IE6 and
Mozilla1.3 on XP, each running a 1.4 JVM.
I tried testing it with Java off, but the Applet
kept appearing in IE (typical) and Mozilla
displayed the message that Java was disabled
(as we intend)]
If u are running a jvm there is no problem. The problem is with people
that do not use the jvm (everyone I know almost always use ie6). So
the best way is to show them a message that this page requires a jvm.
But that isn't user friendly is it.

Anyway thx a lot!
 
A

Andrew Thompson

...
[ And just to clarify, that is in both IE6 and
Mozilla1.3 on XP, each running a 1.4 JVM.
I tried testing it with Java off, but the Applet
kept appearing in IE (typical) and Mozilla
displayed the message that Java was disabled
(as we intend)]
If u are running a jvm there is no problem. The problem is with people
that do not use the jvm (everyone I know almost always use ie6). So
the best way is to show them a message that this page requires a jvm.
But that isn't user friendly is it.

No, the alt tag should take care of no JVM*, and the
JavaVersionApplet should redirect for a v 1.0 or
1.1 VM (since you specify 1.2).

* besides, you don't get a stacktrace in the java
console if there is _no_ JVM

A couple of last (stretching) thoughts,
1) Try it without the redirect,
<PARAM NAME=target VALUE=content>
there may be a problem opening a new window.

2) Try the same page, with the javascript completely
removed. One of the important parts of testing is
to reduce the problem to the smallest possible
example that demonstrates the problem -
and sometimes you find that by doing so, the
problem becomes clear, or disappears.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top