Solved

web page communication with applet

Posted on 1997-03-08
8
358 Views
Last Modified: 2008-03-10
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.
0
Comment
Question by:ddyer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +2
8 Comments
 

Expert Comment

by:amarshal
ID: 1218992
Make the table one big applet??
0
 
LVL 1

Expert Comment

by:tatti
ID: 1218993
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.

0
 

Author Comment

by:ddyer
ID: 1218994
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.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:cmg
ID: 1218995
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 ;)
0
 

Author Comment

by:ddyer
ID: 1218996
"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)
 {..}


0
 

Expert Comment

by:cmg
ID: 1218997
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.
0
 

Expert Comment

by:amarshal
ID: 1218998
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.
0
 
LVL 3

Accepted Solution

by:
garik earned 50 total points
ID: 1218999
ddyer, LiveConnect solution on your web page is elegant enough and is the best one can come up with, but only for Netscape browser - the only one supporting LiveConnect technology for applet-browser communication. For others, you have to add browser-identification script to avoid a bunch of error messages on non-existing object.
Your launchwith() function can be improved a little bit by adding check on existence of Java objects:
if(document.LoaApplet != null && document.LoaApplet.SetGameName != null)
This would prevent errors while the applet is loading.

    Less elegant, but more universal solution without using LiveConnect is to modify your launchwith() function to generate an HTML in a new window and write there applet call with corresponding game name:

win = null;

function launchwith(game) {
if(win == null) {
    win = window.open("", "appletWindow", width=400, height=300, ...);
}
win.document.write
    ("<HTML><HEAD><TITLE>Lines of Action</TITLE></HEAD>");
win.document.write
    ("<BODY><APPLET ...><PARAM NAME='game' VALUE="+game+...
...

Subsequent calls to launchwith() will overwrite the contents of appletWindow with a new game parameter for the applet.

Hope it solves your problem.
Good luck!
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question