Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSObject, how can I call JS function from Java Applet ?

 
AndXlr andrzej
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
The code below working, but the calling JS not....and nothing happens , no error.
I did it with help from this side :
http://java.sun.com/j2se/1.5.0/docs/guide/plugin/developer_guide/java_js.html
Anybody know what is wrong?
Thanks!

HTML :


Java Applet

 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

These are exclusively English-language forums; please supply an English translation of your question, or it is liable to be deleted.

What happens if you run this code? Are there any error messages, either from JavaScript or from Java?
 
AndXlr andrzej
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:Welcome to JavaRanch.

These are exclusively English-language forums; please supply an English translation of your question, or it is liable to be deleted.

What happens if you run this code? Are there any error messages, either from JavaScript or from Java?


Hi Ulf ,
I am sorry, I mixed up languages

I don't get any Error, on my TextFeld I see massege from :

DIe beide Zahlen sind :12 12
So this code part is not working :
"
and after this nothing happens...

thank you!
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure what's going on, but LiveConnect (the Java/JavaScript bridge technology) is notoriously fickle. I'd recommend to use the Common DOM API instead, if at all possible.
 
Rok Ć telcer
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

On the first look I'd say that there could be two potential problems in your example/code:

1. I'm not sure, if you're calling the JSObject.getWindow in a right place
As far as I know, you should call it in Applets init() method.
Example:

2. Following code is missing in your HTML:

Hope this helps.



Regards,
Rok
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic