-
- function browse() {
- var guiPkgs = new JavaImporter(java.awt, java.awt.event,
- javax.swing, javax.swing.undo,
- javax.swing.event, javax.swing.text);
- with (guiPkgs) {
- var desktop = null;
- if (Desktop.isDesktopSupported()) {
- desktop = Desktop.getDesktop();
- } else {
- alert("no desktop support");
- return;
- }
- if (desktop.isSupported(Desktop.Action.BROWSE)) {
- desktop.browse(new java.net.URI("http://blog.csdn.net/dashi99"));
- } else {
- alert("no browser support");
- }
- }
- }
- if (this.application != undefined) {
- this.application.addTool("Browse", browse);
- }
- import java.io.*;
- import javax.script.*;
- public class Main
- {
- public Main()
- {
- try {
- ScriptEngineManager m = new ScriptEngineManager();
- ScriptEngine engine = m.getEngineByName("javascript");
- if ( engine != null )
- {
- InputStream is = this.getClass().getResourceAsStream("browse.js");
- Reader reader = new InputStreamReader(is);
- engine.eval(reader);
- Invocable invocableEngine = (Invocable)engine;
- invocableEngine.invokeFunction("browse");
- }
- }
- catch ( Exception e ) {
- e.printStackTrace();
- }
- }
- public static void main(String[] args)
- {
- Main m = new Main();
- }
- }