xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From J Aaron Farr <jaaronf...@yahoo.com>
Subject Scripting Batik...
Date Fri, 02 Aug 2002 17:40:42 GMT
Does anyone have a nice example showing how to use javascript (in an svg file
displayed in batik) to call java methods?

I was looking at Mozilla's Rhino documentation (the javascript package used in
Batik).  At http://www.mozilla.org/rhino/scriptjava.html they have a nice
example of scripting java using LiveConnect, part of Rhino.  I thought this
would help in one of my current projects, so I included the following in an svg
document:

	function testjs(){
          importPackage(java.awt);
	  var frame = new Frame("JavaScript");
	  frame.show();
	  frame.setSize(new Dimension(200,100));
	  var but = new Button("OK");
	  frame.add(but);
	  frame.show();
	}

Then, on a <text> object, I added an "onclick" attribute and set it to
"testjs()".  I then loaded the svg file in a Batik SVGCanvas object.  Sure
enough, when I clicked the text, a little java frame and button popped up.

Cool.

So then I wanted to open one of my own frames, already defined in another part
of my package.  So I changed the javascript to something like this:

	function testjs(){
	 importPackage(Packages.mypackage);
	 var b = new MyFrame();
	 b.setUrl("http://myserver.com");
	 b.show();
	}

Now, the jar file that holds the batik browser I have contains both the batik
libraries and also my own package.  So I'm thinking they should be all in the
classpath.  But when I click on the text now, I get an error message saying
"MyFrame()" is not a defined function.

Does anyone know what I'm doing wrong here?  Anyone else know how to use
javascript to call some of my java classes and methods?

Thanks for any tips!
jaaron

__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Mime
View raw message