Package netscape.javascript

Examples of netscape.javascript.JSObject


      new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          try {
            URL location = new URL(urlField.getText());
            System.out.println("going to URL: " + location);
            JSObject window = JSObject.getWindow(TrivialApplet.this);
            if (window != null) {
              //window.eval("alert('going to location " + location + "');");
              window.eval("println('" + location + "')");
            }
            getAppletContext().showDocument(location, "_new");
          } catch (MalformedURLException mfue) {
          }
        }
View Full Code Here


      showStatus("See you later!");
    return true;
    }
   
  public void print(String message) {
    JSObject window = JSObject.getWindow(this);
    Object[] args = { message };
    window.call("println", args);
    }
View Full Code Here

  public void saveText(String text, String fileNameProposal)
      throws UnsupportedEncodingException {
    if (webWrapper.getContainer() instanceof Applet) {
      System.out.println(text);
      JSObject jsRoot = webWrapper.getJsRoot();
      JSObject window = (JSObject) jsRoot.getMember("window");
      String dataUri = "data:text/plain;charset=utf-8,"
          + URLEncoder.encode(text, "UTF-8").replace("+", "%20");
      Object[] params = new Object[] { dataUri, "_blank" };
      window.call("open", params);
    } else {
      JFileChooser fc = new JFileChooser();
      fc.setSelectedFile(new File(fileNameProposal));
      if (fc.showSaveDialog(webWrapper.getContainer()) == JFileChooser.APPROVE_OPTION) {
        File file = fc.getSelectedFile();
View Full Code Here

  public Location(Visualizer webWrapper) {
    this.webWrapper = webWrapper;
  }

  private JSObject getJSLocation() {
    JSObject jsRoot = webWrapper.getJsRoot();
    if (jsRoot != null) {
      JSObject document = (JSObject) jsRoot.getMember("document");
      return (JSObject) document.getMember("location");
    }
    return null;
  }
View Full Code Here

    }
    return null;
  }

  public String getHref() {
    JSObject jsLoc = getJSLocation();
    if (jsLoc == null) {
      return "";
    }
    return jsLoc.getMember("href").toString();
  }
View Full Code Here

    }
    return jsLoc.getMember("href").toString();
  }

  public void setHref(String href) {
    JSObject jsLoc = getJSLocation();
    if (jsLoc == null)
      try {
        Desktop.getDesktop().browse(URI.create(href));
      } catch (Exception e) {
        e.printStackTrace();
      }
    else
      jsLoc.setMember("href", href);
  }
View Full Code Here

    return "This applet simulates a JavaScript web environment to run an aichallenge visualizer.";
  }

  public void run() {
    try {
      final JSObject jsRoot = JSObject.getWindow(this);
      webWrapper = new Visualizer(this, getWidth(), getHeight(), false);
      webWrapper.setJsRoot(jsRoot);
      HTMLDocument document = webWrapper.getDomWindow().getDocument();
      ScriptableObject options = webWrapper.construct("Options", null);
      Object config = null;
View Full Code Here

     *  is defined in all tests.  Parse the testcases array, and create a new
     *  TestCase object for each TestCase object it finds.
     */
    public synchronized boolean parseResult() {
        try {
           JSObject testcases = (JSObject) window.getMember("testcases");
            file.totalCases = ((Number) ((JSObject) testcases).getMember("length")).intValue();
            System.out.println( "testcases.length is " + file.totalCases );
            for ( int i = 0; i < file.totalCases; i++ ) {
                JSObject tc  = (JSObject) ((JSObject) testcases).getSlot(i);

                TestCase nc = new TestCase(
                    tc.getMember("passed") == null ? "null" : tc.getMember("passed").toString(),
                    tc.getMember("name") == null ? "null " : tc.getMember("name").toString(),
                    tc.getMember("description") == null ? "null " : tc.getMember("description").toString(),
                    tc.getMember("expect") == null ? "null " : tc.getMember("expect").toString(),
                    tc.getMember("actual") == null ? "null " : tc.getMember("actual").toString(),
                    tc.getMember("reason") == null ? "null " : tc.getMember("reason").toString()
                );

                file.caseVector.addElement( nc );

                if ( nc.passed.equals("false") ) {
View Full Code Here

    public ExampleApplet3() throws HeadlessException {
        super();
    }

    public void paint(Graphics g) {
        JSObject window = JSObject.getWindow(this);
        JSObject document = (JSObject) window.getMember("document");
        JSObject location = (JSObject) document.getMember("location");
       
        g.drawString("Title: " + document.getMember("title"), 10, 20);
        g.drawString("URL: " + location.getMember("href"), 10, 40);
       
        window.eval("getMessageFromApplet(\"Hello from the Java applet!\")");
       
    }
View Full Code Here

      repaint();
    }
  }

  public void executeJS(short[] pcmData) {
    JSObject j = JSObject.getWindow(this);
    j.call("passAudio", new Object[] {pcmData});
  }
View Full Code Here

TOP

Related Classes of netscape.javascript.JSObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.