Link to home
Start Free TrialLog in
Avatar of ddyer
ddyer

asked on

web page communication with applet

Refer to web page
http://www.andromeda.com/people/ddyer/loa/tournament-1.html

I would like to modify is such that the cells in the table
would push the "launch" button, if necessary, and pass the
identity of the cell to the applet.  There ought to be a
better way to do this than to have an applet running in
every cell.
Avatar of amarshal
amarshal

Make the table one big applet??
I agree with amarshal, that would seem to be the best way of doing it.
Of course, if you run a single applet in every cell, loading them should be quite fast as they all have the same classes and only their parameters differ. That would be the quick'n'dirty approach, I suppose.

Avatar of ddyer

ASKER

I considered and rejected both of those solutions before posting
the question.

One big applet is not an attractive solution, because it would
have to draw the table too.

Lots of identical applets is not attractive becauase launching
one new applet per cell wouldn't scale very well.  Guaranteed
to break the browser eventually.
If you aren't able to make the table one big applet, then you are asking an applet to get events happening outside itself, which means changing the browser behaviour - not a Java problem!

But you could take the applet off this page, and put a normal html link in each table box. These would each link to a different page which just contains the applet with the parameters set for that game (so you have "game1.html", "game2.html" etc, where all the gamex.html files just have the applet). Then following the link would take you to a blank page in which the applet would run for that game.

Or, if you don't want all these extra files, how about replacing the launch button with a List item so that the user selects the game they want from that?

I realise neither is really what you want, but I don't think what you want can be done ;)
Avatar of ddyer

ASKER

"You can't do that" isn't the answer I wanted, so I did my own
research.  The answer is to use a javascript form like:

 <script> document.AppletName.DoSomething("argument"); </script>

to use an applet invoked with
 <Applet name="AppletName" ...></applet>

and to give the applet a public method like
 public void DoSomething(String arg)
 {..}


I'm sorry, I assumed you were after a Java answer.
The problem with using Javascript is that many people
(myself certainly included) disable Javascript on their
browsers because of the security holes.
Returning to the 'One Big Applet' approach, drawing the table is very simple.  Just use GridLayout to space things, placing one button in each cell.

There are many inconsistencies with Javascript between browsers and they are not as likely to work as Java.
ASKER CERTIFIED SOLUTION
Avatar of garik
garik

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial