Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

web page communication with applet

Posted on 1997-03-08
8
Medium Priority
?
374 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
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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 100 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

Industry Leaders: 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!

Question has a verified solution.

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

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses

885 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