> I'm a french beginner in Java, so please forgive my poor knowledges and my
> poor english.
> I made an applet ..
URL?
>..and put in in a jar file (named myjar.jar)
> I wrote html like : <applet ... archive=myjar.jar> with some parameters.
> In my applet I get these parameters with getParameter() and put them in
> global variables :
>
> I have a class named MyGlobalClass with static fields :
Why? That would ensure every object of that class
would have access to only a single static field.
27 Objects -> 1 static field.
> Something strange happens :
> When I run one instance of the applet at a time it works fine.
> But when I run 2 instances of that same applet in the same html page with
> different parameters these two instances seem to interfere with each other.
Make those 'static' declarations, instance declarations,
then each time a class creates an object if that class,
it will have an unique gtoups of attributes / properties.
HTH

Signature
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
JFA - 30 Aug 2004 18:24 GMT
> > I have a class named MyGlobalClass with static fields :
>
> Why? That would ensure every object of that class
> would have access to only a single static field.
> 27 Objects -> 1 static field.
Because I need that several classes share the access to this value.
For instance say that it's a font name and some Labels in Class1, Canvas in
Class2, etc. have to get this font name value.
> > Something strange happens :
> > When I run one instance of the applet at a time it works fine.
[quoted text clipped - 4 lines]
> then each time a class creates an object if that class,
> it will have an unique gtoups of attributes / properties.
If I create an instance of MyGlobalClass the problem will be the same with
that instance to be access from Class1, Class2, etc.
Where am I wrong ?
Is it not a good idea to have some values with global access ?
JFA
thufir.hawat@mail.com - 30 Aug 2004 19:54 GMT
[..]
>> Make those 'static' declarations, instance declarations,
>> then each time a class creates an object if that class,
[quoted text clipped - 5 lines]
> Is it not a good idea to have some values with global access ?
> JFA
perhaps you're thinking of a utility class, like Math. Math constants
like pi (not an *exact* value, of course) yet there are no instances of
Math. simply use a getter to get these primitives you seek?
my 2 cents.
Thufir Hawat
> What could I do to preserve the values of the variables of each
> instances ?
Just for fun, AFAIK adding the MAYSCRIPT to the Applet will do that as a
"side-effect".
Bye.

Signature
Real Gagnon from Quebec, Canada
* Looking for Java or PB snippets ? Visit Real's How-to
* http://www.rgagnon.com/howto.html