Java Applet vs JavaScript

Trying to find pros and cons for Applet and JavaScript. Anyone know any or a good place to look?
Thanks

I suppose it depends on what you ultimately want to see. In many ways (many) JavaScript and Applets are not comparable. And you can use Javascript with Applets and vice versa. I have a web application I work on that uses lots of JS with DHTML and it also communicates with an applet, and the applet calls JS stuff as well.
Trying to use JS/DHMTL for very complex GUIs is going to be slower performance then an applet, but probably faster download/start time. Applets also should be using the Java Plug-in which the user would have to pre-install. Netscape 7 has no built-in JVM anymore, and the built-in ones in Netscape 4.7 and IE are both old (JDK 1.8) and buggy.
I agree with your advantages. As for the disadvantages:
1. For non-programmers learning curve can be steep.Who is the target user? A developer? The client browser user wouldn't care about this.
2. Not standard support for Javascript across browsers esp. DOMYes, however, if you can restrict people to IE6 and Netscape 7, then you will find that the differences are minimal. Nothing at all like the difference between them and Netscape 4.7. I'm not up on the latest Opera's support, however.
3. Web page useless if script does not work!!"does not work" sounds like a development problem. Good, correct code will work.
4. Javascript may be disabled by browser reading HTML file no control over thisYes, but if you A) have proper checking you can be sure it's enabled, and B) applets can also be enabled.
5. Anyone can see the JavaScript source code by viewing the
HTML document source. Thus you could not create a secure
multiple-choice test in JavaScript; it would be very easy to
see the answers!While this is generally true, you can do some tricks to solve that type of problem. Lets take this example. You can find Javascript code for creating MD5 hashes, and you can then use that to store the hash of the answers in the page and use the MD5 code to compare the given answers to the real ones. This type of thing is not good for all, of course.
6.Even though JavaScript is a standard, different browsers
interpret JavaScript differently, and some commands that work
fine on one browser simply do not work on another. You must
carefully test your JavaScript code on all browsers to make
sure it runs correctly.This is basically the same type of problem as #2 above, and I would give the same answer. Ultimately, you have to limit yourself to certain browsers/versions. But if the user wants to see it, there's little you can do.
As Sue said, Flash is pretty robust and more secure, since it's easy enough to decompile applets. And server side things would be better security as well, if that's a big issue.

Similar Messages

  • Java Applet to Javascript Communication

    There is a Java Applet which digitally signs files after taking
    private key from a smart card.This applet takes external files.
    I want to do this "Generate digital signature of a web page with the
    help of an applet of which the applet is itself a part"
    I am trying using Java Applet to Javascript Communication.
    I am able to access the object which represents the HTML document.
    That abject is represented by document itself.
    Now I have to somehow generate the whole webpage i.e. like we view in a
    notepad like this:
    <HTML>
    <Title>my page</title>
    Then write into a file and then that file can be signed.
    This is what I feel.
    In C#.net there is a method .innerhtml.
    Does such kind of a method exists in Java.???
    I m searching but cudn't get till now.
    Will serialization work??

    Kindly forget the previous post. Read the following:
    JSObject browserWindow = JSObject.getWindow(this);
    JSObject doc = (JSObject)browserWindow.getMember("document");
    Here doc represents the object of the HTML document.
    This is accessed using Java Applet JavaScript Communication.
    I want to serialize the object represented by doc.
    Then write it into a file and generate it's digital signature.
    In the below written line the parameter fileName is passed.
    CertificationChainAndSignatureBase64 signingResult = signFile(fileName);
    For this I have added few lines in the code written below.
    see first 10-30 lines. Though this code gets compiled but it is not running. When I want to sign the file , it throws an error
    "Unexpected error:sun.plugin.javascript.ocx.JSObject"
    This code is just one class. Two other classes are needed to completely test the code.
    Should I post them ??
    Kindly see what is the error.
    I will be highly grateful and Sorry for confusing in the previous mail...
    private void signSelectedFile() {
    try {
    // Get the file name to be signed from the form in the HTML document
    JSObject browserWindow = JSObject.getWindow(this);
    JSObject mainForm = (JSObject) browserWindow.eval("document.forms[0]");
    String fileNameFieldName = this.getParameter(FILE_NAME_FIELD_PARAM);
    JSObject fileNameField = (JSObject) mainForm.getMember(fileNameFieldName);
    //This is another modification
    //String fileName = (String) fileNameField.getMember("value");
                   //here we get the document......
    JSObject doc = (JSObject)browserWindow.getMember("document");
    //String docum = doc.toString();
    String thePage = "as";
                   FileOutputStream out = new FileOutputStream(thePage);
                   ObjectOutputStream s = new ObjectOutputStream(out);
                   s.writeObject(doc);
                   String fileName = thePage;
                   JOptionPane.showMessageDialog(this, fileName); //"Unexpected error: " + e.getMessage());
    // Perform the actual file signing
    CertificationChainAndSignatureBase64 signingResult = signFile(fileName);
    if (signingResult != null) {
    // Document signed. Fill the certificate and signature fields
    String certChainFieldName = this.getParameter(CERT_CHAIN_FIELD_PARAM);
    JSObject certChainField = (JSObject) mainForm.getMember(certChainFieldName);
    certChainField.setMember("value", signingResult.mCertificationChain);
    String signatureFieldName = this.getParameter(SIGNATURE_FIELD_PARAM);
    JSObject signatureField = (JSObject) mainForm.getMember(signatureFieldName);
    signatureField.setMember("value", signingResult.mSignature);
    } else {
    // User canceled signing
    catch (DocumentSignException dse) {
    // Document signing failed. Display error message
    String errorMessage = dse.getMessage();
    JOptionPane.showMessageDialog(this, errorMessage);
    catch (SecurityException se) {
    se.printStackTrace();
    JOptionPane.showMessageDialog(this,
    "Unable to access the local file system.\n" +
    "This applet should be started with full security permissions.\n" +
    "Please accept to trust this applet when the Java Plug-In ask you.");
    catch (JSException jse) {
    jse.printStackTrace();
    JOptionPane.showMessageDialog(this,
    "Unable to access some of the fields of the\n" +
    "HTML form. Please check the applet parameters.");
    catch (Exception e) {
    e.printStackTrace();
    JOptionPane.showMessageDialog(this, "Unexpected error: " + e.getMessage());
    }

  • Java Applet call javascript problem

    Hi I have a web page as follow and embedded a applet. The applet call the java script, and instead of showing an alarm, the browser show the javascript code. Is that strange ? Any suggestion for this problem.
    HTML:
    ================================================================
    <HTML>
         <HEAD>
         function ShowEmbd()
              alert("Test Applet call Javascript");
         </SCRIPT>
         </HEAD>
         <BODY>
         <FORM NAME="AppletEmbdStart">
              <OBJECT classid="clsid:48B2DD7B-6B52-4DB0-97C9-ECB940113B47" id="CIVON_DEmbdObj" width="0" height="0"></OBJECT>
              <APPLET code="MyApplet.class" width="0" height="0"></APPLET>
         </FORM>
         </BODY>
    </HTML>MyApplet.java
    =========================================================================
    import netscape.javascript.*;
    public class MyApplet extends javax.swing.JApplet
         private JSObject m_win = null;
         private JSObject m_doc = null;
         public void init()
              getJSWin().call("ShowEmbd", null);
         private getJSDoc()
              if(m_doc == bull)
                   m_doc = (JSObject) getJSWin().getMember("document");
              return m_doc;
         private JSObject getJSWin()
              if (m_win == null)
                   m_win = netscape.javascript.JSObject.getWindow(this);
              return m_win;
    }The page was load and it should call the applet MyApplet. The MyApplet should do the init() method and call the Javascript "ShowEmbd()", BUT, instead of show alert from ShowEmbd(), the browser show the code of ShowEmbd() itself ...... It did not run the javascript and shows the alert ??
    The browser shows a message from status bar "The applet not initial" ???? why ???
    Can anyone help ?!

    On first look:
    I am not sure about the Object Tag, but the Applet Tag requires the MAYSCRIPT attribute before Java can call Javascript.

  • When Java applet invokes JavaScript which executes window.showModalDialog, get popup with about:blank

    When using a Java applet that invokes a Javascript function that in turn calls window.showModalDialog, a pop-up dialog that only contains "about:blank" results. Selecting "show desktop" from the Windows 7 taskbar and then viewing the FireFox window results in the true dialog content being displayed. Everything worked properly until very recently (and old versions of FireFox work) and I suspect something was changed in FireFox as a result of the recent Java security failures.

    Hello, I don't know about this specifically but this is what I would try.
    Instead of the string "\u7834\u70C2\u7269\u7A0B\u5E8F\u5458..."
    Set the encoding type in the String constructor first...
    ie:
    new String( "\u7834\u70C2\u7269\u7A0B\u5E8F\u5458...","GB18030");
    Here is a little class I whipped up to show the CharSets that are available to you..
    public class ShowAllCharSets
    ShowAllCharSets()
    Map myMap = Charset.availableCharsets();
    Iterator iterator = myMap.keySet().iterator();
       while (iterator.hasNext())
          System.out.println("Char set name = "+((String)it.next()));
    public static void main(String args[])
       new ShowAllCharSets();
    }Then use the preset charset String with the specific encoding already set for your menu items.
    GB18030 I picked arbitrarily because it is Chinese and you may have to try another.
    Good Luck!
    (T)

  • How do I integrate Java Applet and JavaScript?

    Hi:
    This has been asked before, I have read the archives, yet I'm still left with some doubts, and some posts are VERY old and may not apply today. (sorry, some questions might seem stupid, this is my first applet). The purpose is to create a light weight application for managing certificates stored on a smart card, requesting certificate renewal from a server and installing the issued certificate on the card.
    I need to create an applet (signed) to bridge the gab caused by the security limitations of JavaScript in order to access the smart card on the client. The applet will manage certificates on the card and do client-card interaction, while all client-server and user interaction is done by AJAX/JavaScript.
    So, the applet is actually supposed to be an invisible object embedded on the page that is accessed by the JavaScript. How do I go about this?
    - is there any reason to prefer JApplet over Applet?
    - do the JavaScript need to invoke start() or init() or is this done on page load?
    - are there limitations on data exchange with the applet (ie. only string types)?
    - how do I throw exceptions from the applet to the calling script?
    and: will is it better to let JavaScript do all http to keep the applet light, or to let the applet fetch files given a URL (to fetch the new certificate)?
    If the applet is stored in a jar-file, how do I indicate which class/method to invoke? Do the JavaScript have access to public methods only?
    Thanks for your advice and suggestions,
    Erik

    Hi,
    Are you still interested?
    I can work with you over this.
    Adil

  • Run Priviliged Code in a Java Applet

    I am calling a Java applet from Javascript. The Java code needs to run in privileged mode.  Eventually it is going to display a file chooser which will display files from the local hard disk, but for now it just returns a simple dummy value.  The problem I am having is that the call from JavaScript to Java returns PrivilegedActionException. The applet is in a signed Jar file.  I'm running 8u25.
    Here's the Java class:
        // Java code
        public class OHLib extends Applet {
            public String getFile() {
                String result;
                try {
                    result = (String) AccessController.doPrivileged(new PrivilegedAction() {
                        public String run() {
                            // JFileChooser code will go here
                            return "xxx";
                } catch (Exception e) {
                    e.printStackTrace();
                return result;
    Can anybody tell me what's wrong with this code?  I would also be interested to know why the above try/catch block is not catching the exception.  The only place I see the exception is in the browser F12 developer tools.
    Here's the JavaScript code:
        function BrowseForFile() {
            var x;
            try {
                 // this code generates PrivilegedActionException
                 x = ohApplet.getFile();
            } catch (e) {
                 console.log(e);
    The applet is deployed on my web page as follows:
    <script src="/plugins/deployJava.js"></script>
    <script>
         var attributes = {
             id:'ohApplet',
             code:'OHLib',
             codebase: 'java',
             archive: 'OHLib.jar',
             width:1,
             height:1,
         var parameters = {
          jnlp_href: 'OHLib.jnlp',
          classloader_cache: 'false',
         deployJava.runApplet(attributes, parameters, '1.8');
    <script>
    The applet is in a signed jar file, with the following manifest:
    Application-Name: <appname>
    Permissions: all-permissions
    Codebase: <domain>.dev <domain>.com
    Caller-Allowable-Codebase: <domain>.dev <domain>.com
    Application-Library-Allowable-Codebase: <domain>.dev <domain>.com
    The JNLP file is as follows:
        <?xml version="1.0" encoding="UTF-8"?>
        <jnlp spec="1.0+" codebase="" href="">
            <information>
                <title>title</title>
                <vendor>vendor</vendor>
            </information>
            <security>
                <all-permissions />
            </security>
            <resources>
                <j2se version="1.8+" href="http://java.sun.com/products/autodl/j2se" />
                <jar href="OHLib.jar" main="true" />
            </resources>
            <applet-desc
                 main-class="OHLib"
                 name="OHLib"
                 width="1"
                 height="1">
             </applet-desc>
        </jnlp>       

    The problem was that I was not including the anonymous inner class (OHLib$1.class) in the jar file. My original jar command looked like this:
    jar cfmv OHLib.jar "../../jar_manifest.txt" OHLib.class
    Changing it to below fixed the problem:
    jar cfmv OHLib.jar "../../jar_manifest.txt" OHLib.class OHLib$1.class
    Credits go to this page  for the solution.

  • COMMUNICATION BETWEEN JAVASCRIPT AND JAVA APPLET: US$20 AWARD FOR SOLUTION!

    COMMUNICATION BETWEEN JAVASCRIPT AND JAVA APPLET PROBLEM (Easy Filter Java Applet) -
    US$20 TO ANYONE WHO CAN RESOLVE THE PROBLEM
    To forum visitors:
    I am prepared to pay a standard shareware fee of US$20 to a user who can resolve this technical problem.
    If your advice resolves the problem, I'll forward the payment to your postal address (include your
    address with your reply, and also your email address)
    I am attempting to enable a HTML button (using Javascript's onClick command) to directly input a number into one of the parameter text boxes in the Easy Filter Java applet (ie, enter a new color value number in the text field of the standard Colors Multiplicator Filter interface).
    The applet is Freeware and can be downloaded at: http://www.javazoom.net/applets/easyfilter10/EasyFilter10.html
    (It is a very effective bitmap display and editing utility)
    To achieve this, I am trying to access the part of the applet that defines and sets the textbox. The text box is defined in the .class file by accessing the parameter details in the genericfilter.txt file (accompanies the .class files). I need to access 'private String appletInitialize()' and then one of the 'textFieldParameters' which sets the textbox.
    I understand the basic syntax for referencing the applet:
    document.appletname.setString("An example"). However, accessing the text fields in this applet is more complex!!
    Please can you recommend the correct Javascript syntax to achieve communication with the applet.
    Thank you for your kind assistance.
    JM Graham
    [email protected]
    The Java source code for the applet: EasyFilter.class
    # Easy Filter - E.B/JavaZOOM 1999 #
    # Contact: [email protected] #
    # http://javazoom.hypermart.net #
    /* Originally compiled from EasyFilter.java */
    import java.awt.*;
    import java.io.*;
    import java.net.*;
    import java.applet.Applet;
    import java.awt.event.KeyEvent;
    import java.awt.event.KeyListener;
    import java.awt.image.MemoryImageSource;
    import java.awt.image.PixelGrabber;
    import java.util.Vector;
    public synchronized class EasyFilter extends Applet implements KeyListener
    private String paramFileName;
    private Color bgColor;
    private Color fgColor;
    private Color parColor;
    private Color sepColor;
    private Color titleColor;
    private Color helpColor;
    private int WinWidth;
    private int WinHeight;
    private String title;
    private String logoFileName;
    private String originalImageFileName;
    private String filteredCaption;
    private String originalCaption;
    private Vector paramsName;
    private Vector paramsValue;
    private Vector paramsComment;
    private Panel panelParameters[];
    private Label labelParameters[];
    private TextField textFieldParameters[];
    private Label labelComments[];
    private int nbParameters;
    private ScrollPane scrollPaneParams;
    private Panel panelParams;
    private Image theLogo;
    private Image theOriginalImage;
    private Image theFilteredImage;
    private int theOriginalPixelArray[];
    private int logoWidth;
    private int logoHeight;
    private int imageWidth;
    private int imageHeight;
    private drawCanvas canvasTitle;
    private Panel panelTitle;
    private Label labelTitle;
    private Panel panelImages;
    private Panel panelOriginalImage;
    private drawCanvas canvasOriginalImage;
    private Label labelOriginalImage;
    private Panel panelFilteredImage;
    private drawCanvas canvasFilteredImage;
    private Label labelFilteredImage;
    private Panel panelHelp;
    private Label labelHelp;
    private int Yspc;
    private FilterImplementation theFilter;
    public void init()
    String string = null;
    string = appletInitialize();
    setBackground(bgColor);
    if (string != null)
    removeAll();
    setBackground(Color.white);
    setForeground(Color.black);
    Label label = new Label(new StringBuffer("Error: ").append(string).toString(), 1);
    Panel panel = new Panel();
    panel.add(label);
    add(panel);
    setLayout(new FlowLayout(1, 5, Yspc));
    public void keyPressed(KeyEvent keyEvent)
    panelHelp.removeAll();
    boolean flag = true;
    if (KeyEvent.getKeyText(keyEvent.getKeyCode()).equals("Enter"))
    for (int i = 0; i < nbParameters; )
    try
    paramsValue.setElementAt(new Double(textFieldParameters.getText()), i);
    i++;
    catch (NumberFormatException e)
    labelHelp.setText(labelParameters[i].getText() + ": Not a Number");
    flag = false;
    break;
    if (flag == 1)
    labelHelp.setText(" .... Running, please wait .... ");
    labelHelp.setAlignment(1);
    panelHelp.add(labelHelp);
    panelHelp.doLayout();
    theFilter.updateParameters(paramsValue);
    theFilter.computeFilter();
    theFilteredImage = createImage(new MemoryImageSource(theFilter.getFinalImageWidth(), theFilter.getFinalImageHeight(), theFilter.getFinalImageBuffer(), 0, theFilter.getFinalImageWidth()));
    canvasFilteredImage.setImage(theFilteredImage);
    canvasFilteredImage.setBounds(0, 0, theFilter.getFinalImageWidth(), theFilter.getFinalImageHeight());
    canvasFilteredImage.repaint();
    panelHelp.removeAll();
    labelHelp.setText("- Done -");
    else
    labelHelp.setText("- Press Enter to run the Filter -");
    labelHelp.setAlignment(1);
    panelHelp.add(labelHelp);
    panelHelp.doLayout();
    public void keyReleased(KeyEvent keyEvent)
    public void keyTyped(KeyEvent keyEvent)
    private String appletInitialize()
    WinWidth = size().width;
    WinHeight = size().height;
    if (getParameter("bgcolor") == null)
    bgColor = new Color(0, 0, 40);
    else
    bgColor = new Color(Integer.parseInt(getParameter("bgcolor"), 16));
    if (getParameter("fgcolor") == null)
    fgColor = new Color(255, 255, 255);
    else
    fgColor = new Color(Integer.parseInt(getParameter("fgcolor"), 16));
    if (getParameter("sepcolor") == null)
    sepColor = new Color(158, 128, 128);
    else
    sepColor = new Color(Integer.parseInt(getParameter("sepcolor"), 16));
    if (getParameter("parcolor") == null)
    parColor = new Color(24, 24, 24);
    else
    parColor = new Color(Integer.parseInt(getParameter("parcolor"), 16));
    if (getParameter("titlecolor") == null)
    titleColor = new Color(255, 255, 0);
    else
    titleColor = new Color(Integer.parseInt(getParameter("titlecolor"), 16));
    if (getParameter("helpcolor") == null)
    helpColor = new Color(0, 255, 255);
    else
    helpColor = new Color(Integer.parseInt(getParameter("helpcolor"), 16));
    paramsName = new Vector();
    paramsValue = new Vector();
    paramsComment = new Vector();
    paramFileName = getParameter("paramfile");
    String string = readParams(paramFileName);
    if (string != null)
    return string;
    MediaTracker mediaTracker = new MediaTracker(this);
    theOriginalImage = getImage(getDocumentBase(), originalImageFileName);
    mediaTracker.addImage(theOriginalImage, 0);
    if (logoFileName != null)
    theLogo = getImage(getDocumentBase(), logoFileName);
    mediaTracker.addImage(theLogo, 1);
    try
    mediaTracker.waitForAll();
    catch (InterruptedException e1)
    return "Error while loading image";
    if (mediaTracker.isErrorAny())
    return "Error while loading image";
    if (logoFileName != null)
    logoWidth = theLogo.getWidth(this);
    logoHeight = theLogo.getHeight(this);
    imageWidth = theOriginalImage.getWidth(this);
    imageHeight = theOriginalImage.getHeight(this);
    theOriginalPixelArray = new int[imageWidth * imageHeight];
    PixelGrabber pixelGrabber = new PixelGrabber(theOriginalImage, 0, 0, imageWidth, imageHeight, theOriginalPixelArray, 0, imageWidth);
    try
    pixelGrabber.grabPixels();
    panelTitle = new Panel();
    canvasTitle = new drawCanvas();
    labelTitle = new Label();
    panelTitle.setLayout(new FlowLayout(1, 10, Yspc));
    add(panelTitle);
    panelTitle.setBackground(bgColor);
    panelTitle.add(canvasTitle);
    canvasTitle.setImage(theLogo);
    canvasTitle.setBounds(0, 0, logoWidth, logoHeight);
    labelTitle.setText(title);
    catch (InterruptedException e2)
    return "Internal Error, Try RELOAD !";
    if (title != null)
    panelTitle.add(labelTitle);
    labelTitle.setForeground(titleColor);
    labelTitle.setFont(new Font("Dialog", 1, 14));
    panelImages = new Panel();
    panelOriginalImage = new Panel();
    canvasOriginalImage = new drawCanvas();
    labelOriginalImage = new Label();
    panelFilteredImage = new Panel();
    canvasFilteredImage = new drawCanvas();
    labelFilteredImage = new Label();
    panelImages.setLayout(new FlowLayout(1, 10, Yspc));
    add(panelImages);
    panelImages.setBackground(bgColor);
    panelOriginalImage.setLayout(new BorderLayout(0, 2));
    panelImages.add(panelOriginalImage);
    panelOriginalImage.setBackground(Color.black);
    panelOriginalImage.add("Center", canvasOriginalImage);
    canvasOriginalImage.setImage(theOriginalImage);
    canvasOriginalImage.setBounds(0, 0, imageWidth, imageHeight);
    labelOriginalImage.setText(originalCaption);
    labelOriginalImage.setAlignment(1);
    panelOriginalImage.add("South", labelOriginalImage);
    labelOriginalImage.setBackground(Color.lightGray);
    labelOriginalImage.setForeground(Color.black);
    labelOriginalImage.setFont(new Font("SansSerif", 0, 10));
    panelFilteredImage.setLayout(new BorderLayout(0, 2));
    panelImages.add(panelFilteredImage);
    panelFilteredImage.setBackground(Color.black);
    panelFilteredImage.add("Center", canvasFilteredImage);
    theFilter = new FilterImplementation(paramsValue, theOriginalPixelArray, imageWidth, imageHeight);
    theFilter.computeFilter();
    theFilteredImage = createImage(new MemoryImageSource(theFilter.getFinalImageWidth(), theFilter.getFinalImageHeight(), theFilter.getFinalImageBuffer(), 0, theFilter.getFinalImageWidth()));
    canvasFilteredImage.setImage(theFilteredImage);
    canvasFilteredImage.setBounds(0, 0, theFilter.getFinalImageWidth(), theFilter.getFinalImageHeight());
    labelFilteredImage.setText(filteredCaption);
    labelFilteredImage.setAlignment(1);
    panelFilteredImage.add("South", labelFilteredImage);
    labelFilteredImage.setBackground(Color.lightGray);
    labelFilteredImage.setFont(new Font("SansSerif", 0, 10));
    scrollPaneParams = new ScrollPane(0);
    panelParams = new Panel();
    nbParameters = paramsName.size();
    int i = WinHeight - (33 + 7 * Yspc + logoHeight + imageHeight + 23);
    if (i < Yspc + 2 + 24)
    i = Yspc + 2 + 24;
    scrollPaneParams.setBounds(0, 0, WinWidth - 10, i);
    panelParams.setLayout(new GridLayout(nbParameters, 1, 5, Yspc / 2));
    scrollPaneParams.add(panelParams);
    panelParams.setBackground(sepColor);
    panelParameters = new Panel[nbParameters];
    labelParameters = new Label[nbParameters];
    textFieldParameters = new TextField[nbParameters];
    labelComments = new Label[nbParameters];
    for (int j = 0; j < nbParameters; j++)
    panelParameters[j] = new Panel();
    panelParameters[j].setLayout(new FlowLayout(0, 5, 1));
    panelParams.add(panelParameters[j]);
    panelParameters[j].setBackground(parColor);
    labelParameters[j] = new Label();
    labelParameters[j].setText((String)paramsName.elementAt(j));
    panelParameters[j].add(labelParameters[j]);
    labelParameters[j].setForeground(fgColor);
    labelParameters[j].setFont(new Font("Dialog", 1, 12));
    textFieldParameters[j] = new TextField(8);
    textFieldParameters[j].setText(paramsValue.elementAt(j).toString());
    panelParameters[j].add(textFieldParameters[j]);
    textFieldParameters[j].setBackground(fgColor);
    textFieldParameters[j].addKeyListener(this);
    labelComments[j] = new Label();
    labelComments[j].setText((String)paramsComment.elementAt(j));
    panelParameters[j].add(labelComments[j]);
    labelComments[j].setForeground(fgColor);
    add(scrollPaneParams);
    panelHelp = new Panel();
    labelHelp = new Label();
    panelHelp.setLayout(new FlowLayout(1, 5, 0));
    add(panelHelp);
    panelHelp.setBackground(bgColor);
    labelHelp.setText(" Change colour values and press enter ");
    labelHelp.setAlignment(1);
    panelHelp.add(labelHelp);
    labelHelp.setForeground(helpColor);
    return null;
    private String readParams(String string1)
    Object object1;
    String string2;
    if (string1 == null)
    return "Filename of filter's parameters needed";
    try
    URL uRL = new URL(getDocumentBase(), string1);
    URLConnection uRLConnection = uRL.openConnection();
    uRLConnection.setDoInput(true);
    uRLConnection.setUseCaches(false);
    BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(uRLConnection.getInputStream()));
    string2 = null;
    catch ()
    return object1.getMessage();
    catch ()
    return object1.getMessage();
    catch ()
    return object1.getMessage();
    if (bufferedReader != null)
    Object object2;
    try
    for (object2 = bufferedReader.readLine(); object2 != null && string2 == null; object2 = bufferedReader.readLine())
    string2 = extractFormat(object2);
    catch ()
    string2 = object2.getMessage();
    finally
    bufferedReader.close();
    if (string2 != null)
    return string2;
    else
    return null;
    private String extractFormat(String string1)
    if (string1.length() == 0)
    return null;
    int i = 0;
    int j = string1.indexOf(" ", i);
    if (j == -1)
    return "Bad format error (space missing)";
    String string2 = string1.substring(i, j);
    if (string2.equals("TITLE"))
    i = j;
    j = string1.indexOf(34, i);
    if (j == -1)
    return "Bad format (Double quote in TITLE missing)";
    i = j + 1;
    j = string1.indexOf(34, i);
    if (j == -1)
    return "Bad format (Double quote in TITLE missing)";
    title = string1.substring(i, j);
    return null;
    if (string2.equals("ORIGINALCAPTION"))
    i = j;
    j = string1.indexOf(34, i);
    if (j == -1)
    return "Bad format (Double quote in ORIGINALCAPTION missing)";
    i = j + 1;
    j = string1.indexOf(34, i);
    if (j == -1)
    return "Bad format (Double quote in ORIGINALCAPTION missing)";
    originalCaption = string1.substring(i, j);
    return null;
    if (string2.equals("FILTEREDCAPTION"))
    i = j;
    j = string1.indexOf(34, i);
    if (j == -1)
    return "Bad format (Double quote in FILTEREDCAPTION missing)";
    i = j + 1;
    j = string1.indexOf(34, i);
    if (j == -1)
    return "Bad format (Double quote in FILTEREDCAPTION missing)";
    filteredCaption = string1.substring(i, j);
    return null;
    if (string2.equals("LOGO"))
    i = j + 1;
    j = string1.length();
    logoFileName = string1.substring(i, j);
    return null;
    if (string2.equals("ORIGINALIMAGE"))
    i = j + 1;
    j = string1.length();
    originalImageFileName = string1.substring(i, j);
    return null;
    if (!string2.equals("PARAM"))
    return null;
    i = j;
    j = string1.indexOf(34, i);
    if (j == -1)
    return "Bad format in a PARAM line";
    i = j + 1;
    j = string1.indexOf(34, i);
    if (j == -1)
    return "Bad format in a PARAM line";
    paramsName.addElement(string1.substring(i, j));
    i = j + 2;
    j = string1.indexOf(32, i);
    if (j == -1)
    return "Bad format in a PARAM line";
    try
    paramsValue.addElement(new Double(string1.substring(i, j)));
    j = string1.indexOf(34, i);
    catch (NumberFormatException e)
    return "Bad format in a PARAM line";
    if (j == -1)
    return "Bad format (Double quote in PARAM comment missing)";
    i = j + 1;
    j = string1.indexOf(34, i);
    if (j == -1)
    return "Bad format (Double quote in PARAM comment missing)";
    paramsComment.addElement(string1.substring(i, j));
    return null;
    public EasyFilter()
    logoHeight = 33;
    Yspc = 5;

    Addition to my above submission
    To clarify, I'll offer the US$20 to the FIRST person who offers me a workable solution to the problem, not to everyone!!!
    JMGRAHAM

  • Call Javascript Function in my JAVA Applet

    Hello every body,
    I would like to be able to call a javascript function in my Java applet.
    I know to call JAVA function with a javascript function but not inverse.
    Someone can help me please ?

    Look at chapters 25/26 (or so) in Sun's Plugin Developer's Guide.

  • Calling a Java Applet - Javascript

    Hey guys,
    I'm still fairly new to Java. I'm having a hard time getting my Applet to run properly.
    Basically, this is what I want it to do:
    I have a web page with a series of fields on it (a form). I have a submit button. When the user clicks the submit button, it activates a Javascript function in a seperate file that validates ALL of these fields. The validation that it does is merely to determine whether or not the fields are blank.
    Once it's accomplished this task, I THEN want it to run a Java applet.
    Everything works up until the point at which it runs the Java applet. I'm not sure how exactly I'm supposed to call the applet from Javascript.
    In every example of a web page that I see that has an applet, it has something that looks like this:
    <APPLET CODE="classname.class >
    </APPLET>That's all fine and good, but the problem is that it automatically calls the Applet then. I don't want it to do that. Is there a way that I can CALL the applet at the very end of a JS file? I mean, I don't want anything to load, no grey boxes or any of that stuff until I actually call it..
    Any idea?
    Thanks!
    Todd

    dude,
    have you managed to call an applet method from firefox?
    I'm not sure it is working at all.
    I've read few articles and everyone is complaining about the same error:
    Error: document.appl01 has no properties
    in the case above the applet was called "appl01"
    I've tried using
    document.applets[0].<the applet method>
    and I've got the same result..

  • Easy way to convert javascript to a java applet?

    Hello all! I am relatively new to java and java programming and had a question about converting a JavaScript to a java applet or even a standalone application. I included the JavaScript code for a checkers game below and wanted to know what would be the easiest way to convert this code if at all possible?
    Thanks in advance,
    Bob
    <SCRIPT language=JavaScript>
    <!--
    version = 1.0;
    // -->
    </SCRIPT>
    <SCRIPT language=JavaScript1.1>
    <!--
    version = 1.1;
    // -->
    </SCRIPT>
    <SCRIPT language=JavaScript>
    <!--
    if (version==1.0)
    document.write("Your browser doesn't have JavaScript 1.1 capabilities. "
    + "This checkers game script only works on Netscape 3+ and MSIE 4+.");
    // -->
    </SCRIPT>
    <SCRIPT language=JavaScript1.1>
    <!--
    // Checkers Game
    // black.gif
    // gray.gif
    // you1.gif -- normal piece (player/red)
    // you2.gif -- highlighted piece
    // you1k.gif -- kinged normal piece
    // you2k.gif -- kinged highlighted piece
    // me1.gif -- normal piece (computer/black)
    // me2.gif -- highlighted piece
    // me1k.gif -- kinged normal piece
    // me2k.gif -- kinged highlighted piece
    function preload() {
    this.length = preload.arguments.length;
    for (var i = 0; i < this.length; i++) {
    this[i] = new Image();
    this.src = preload.arguments[i];
    var pics = new preload("black.gif","gray.gif",
    "you1.gif","you2.gif","you1k.gif","you2k.gif",
    "me1.gif","me2.gif","me1k.gif","me2k.gif");
    var black = -1; // computer is black
    var red = 1; // visitor is red
    var square_dim = 35;
    var piece_toggled = false;
    var my_turn = false;
    var double_jump = false;
    var comp_move = false;
    var game_is_over = false;
    var safe_from = safe_to = null;
    var toggler = null;
    var togglers = 0;
    function Board() {
    board = new Array();
    for (var i=0;i<8; i++) {
    board[i] = new Array();
    for (var j=0;j<8;j++)
    board[i][j] = Board.arguments[8*j+i];
    board[-2] = new Array(); // prevents errors
    board[-1] = new Array(); // prevents errors
    board[8] = new Array(); // prevents errors
    board[9] = new Array(); // prevents errors
    var board;
    Board(1,0,1,0,1,0,1,0,
    0,1,0,1,0,1,0,1,
    1,0,1,0,1,0,1,0,
    0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,
    0,-1,0,-1,0,-1,0,-1,
    -1,0,-1,0,-1,0,-1,0,
    0,-1,0,-1,0,-1,0,-1);
    function message(str) {
    if (!game_is_over)
    document.disp.message.value = str;
    function moveable_space(i,j) {
    // calculates whether it is a gray (moveable)
    // or black (non-moveable) space
    return (((i%2)+j)%2 == 0);
    function Coord(x,y) {
    this.x = x;
    this.y = y;
    function coord(x,y) {
    c = new Coord(x,y);
    return c;
    document.write("<table border=0 cellspacing=0 cellpadding=0 width="+(square_dim*8+8)
    +"<tr><td><img src='black.gif' width="+(square_dim*8+8)
    +" height=4><br></td></tr>");
    for(var j=0;j<8;j++) {
    document.write("<tr><td><img src='black.gif' width=4 height="+square_dim+">");
    for(var i=0;i<8;i++) {
    if (moveable_space(i,j))
    document.write("<a href='javascript:clicked("+i+","+j+")'>");
    document.write("<img src='");
    if (board[i][j]==1) document.write("you1.gif");
    else if (board[i][j]==-1) document.write("me1.gif");
    else if (moveable_space(i,j)) document.write("gray.gif");
    else document.write("black.gif");
    document.write("' width="+square_dim+" height="+square_dim
    +" name='space"+i+""+j+"' border=0>");
    if (moveable_space(i,j)) document.write("</a>");
    document.write("<img src='black.gif' width=4 height="+square_dim+"></td></tr>");
    document.write("<tr><td><img src='black.gif' width="+(square_dim*8+8)
    +" height=4><br></td></tr></table><br>"
    +"<form name='disp'><textarea name='message' wrap=virtual rows=2 cols=40></textarea><br><input "
    +"type=button value=\"Start the Game Over\" onClick=\"location.href+=''\"></form>");
    function clicked(i,j) {
    if (my_turn) {
    if (integ(board[i][j])==1) toggle(i,j);
    else if (piece_toggled) move(selected,coord(i,j));
    else message("First click one of your red pieces, then click where you want to move it");
    } else {
    message("It's not your turn yet. Hang on a sec!");
    function toggle(x,y) {
    if (my_turn) {
    if (piece_toggled)
    draw(selected.x,selected.y,"you1"+((board[selected.x][selected.y]==1.1)?"k":"")+".gif");
    if (piece_toggled && (selected.x == x) && (selected.y == y)) {
    piece_toggled = false;
    if (double_jump) { my_turn = double_jump = false; computer(); }
    } else {
    piece_toggled = true;
    draw(x,y,"you2"+((board[x][y]==1.1)?"k":"")+".gif");
    selected = coord(x,y);
    } else {
    if ((piece_toggled) && (integ(board[selected_c.x][selected_c.y])==-1))
    draw(selected_c.x,selected_c.y,"me1"+((board[selected_c.x][selected_c.y]==-1.1)?"k":"")+".gif");
    if (piece_toggled && (selected_c.x == x) && (selected_c.y == y)) {
    piece_toggled = false;
    } else {
    piece_toggled = true;
    draw(x,y,"me2"+((board[x][y]==-1.1)?"k":"")+".gif");
    selected_c = coord(x,y);
    function draw(x,y,name) {
    document.images["space"+x+""+y].src = name;
    function integ(num) {
    if (num != null)
    return Math.round(num);
    else
    return null;
    function abs(num) {
    return Math.abs(num);
    function sign(num) {
    if (num < 0) return -1;
    else return 1;
    function concatenate(arr1,arr2) {
    // function tacks the second array onto the end of the first and returns result
    for(var i=0;i<arr2.length;i++)
    arr1[arr1.length+i] = arr2[i];
    return arr1;
    function legal_move(from,to) {
    if ((to.x < 0) || (to.y < 0) || (to.x > 7) || (to.y > 7)) return false;
    piece = board[from.x][from.y];
    distance = coord(to.x-from.x,to.y-from.y);
    if ((distance.x == 0) || (distance.y == 0)) {
    message("You may only move diagonally.");
    return false;
    if (abs(distance.x) != abs(distance.y)) {
    message("Invalid move.");
    return false;
    if (abs(distance.x) > 2) {
    message("Invalid move.");
    return false;
    if ((abs(distance.x) == 1) && double_jump) {
    return false;
    if ((board[to.x][to.y] != 0) || (piece == 0)) {
    return false;
    if ((abs(distance.x) == 2)
    && (integ(piece) != -integ(board[from.x+sign(distance.x)][from.y+sign(distance.y)]))) {
    return false;
    if ((integ(piece) == piece) && (sign(piece) != sign(distance.y))) {
    return false;
    return true;
    function move(from,to) {
    my_turn = true;
    if (legal_move(from,to)) {
    piece = board[from.x][from.y];
    distance = coord(to.x-from.x,to.y-from.y);
    if ((abs(distance.x) == 1) && (board[to.x][to.y] == 0)) {
    swap(from,to);
    } else if ((abs(distance.x) == 2)
    && (integ(piece) != integ(board[from.x+sign(distance.x)][from.y+sign(distance.y)]))) {
    double_jump = false;
    swap(from,to);
    remove(from.x+sign(distance.x),from.y+sign(distance.y));
    if ((legal_move(to,coord(to.x+2,to.y+2)))
    || (legal_move(to,coord(to.x+2,to.y-2)))
    || (legal_move(to,coord(to.x-2,to.y-2)))
    || (legal_move(to,coord(to.x-2,to.y+2)))) {
    double_jump = true;
    message("You may complete the double jump or click on your piece to stay still.");
    if ((board[to.x][to.y] == 1) && (to.y == 7)) king_me(to.x,to.y);
    selected = to;
    if (game_over() && !double_jump) {
    setTimeout("toggle("+to.x+","+to.y+");my_turn = double_jump = false;computer();",1000);
    return true;
    function king_me(x,y) {
    if (board[x][y] == 1) {
    board[x][y] = 1.1; // king you
    draw(x,y,"you2k.gif");
    } else if (board[x][y] == -1) {
    board[x][y] = -1.1; // king me
    draw(x,y,"me2k.gif");
    function swap(from,to) {
    if (my_turn || comp_move) {
    dummy_src = document.images["space"+to.x+""+to.y].src;
    document.images["space"+to.x+""+to.y].src = document.images["space"+from.x+""+from.y].src;
    document.images["space"+from.x+""+from.y].src = dummy_src;
    dummy_num = board[from.x][from.y];
    board[from.x][from.y] = board[to.x][to.y];
    board[to.x][to.y] = dummy_num;
    function remove(x,y) {
    if (my_turn || comp_move)
    draw(x,y,"gray.gif");
    board[x][y] = 0;
    function Result(val) {
    this.high = val;
    this.dir = new Array();
    function move_comp(from,to) {
    toggle(from.x,from.y);
    comp_move = true;
    swap(from,to);
    if (abs(from.x-to.x) == 2) {
    remove(from.x+sign(to.x-from.x),from.y+sign(to.y-from.y));
    if ((board[to.x][to.y] == -1) && (to.y == 0)) king_me(to.x,to.y);
    setTimeout("selected_c = coord("+to.x+","+to.y+");piece_toggled = true;",900);
    setTimeout("bak=my_turn;my_turn=false;toggle("+to.x+","+to.y+");my_turn=bak;",1000);
    if (game_over()) {
    setTimeout("comp_move = false;my_turn = true;togglers=0;",600);
    message("Ok. It's your turn. You may make your move.");
    return true;
    function game_over() { // make sure game is not over (return false if game is over)
    comp = you = false;
    for(var i=0;i<8;i++) {
    for(var j=0;j<8;j++) {
    if(integ(board[i][j]) == -1) comp = true;
    if(integ(board[i][j]) == 1) you = true;
    if (!comp) message("You beat me!");
    if (!you) message("Gotcha! Game over.");
    game_is_over = (!comp || !you)
    return (!game_is_over);
    // the higher the jump_priority, the more often the computer will take the jump over the safe move
    var jump_priority = 10;
    function computer() {
    // step one - prevent any jumps
    for(var j=0;j<8;j++) {
    for(var i=0;i<8;i++) {
    if (integ(board[i][j]) == 1) {
    if ((legal_move(coord(i,j),coord(i+2,j+2))) && (prevent(coord(i+2,j+2),coord(i+1,j+1)))) {
    return true;
    } if ((legal_move(coord(i,j),coord(i-2,j+2))) && (prevent(coord(i-2,j+2),coord(i-1,j+1)))) {
    return true;
    } if (board[i][j] == 1.1) {
    if ((legal_move(coord(i,j),coord(i-2,j-2))) && (prevent(coord(i-2,j-2),coord(i-1,j-1)))) {
    return true;
    } if ((legal_move(coord(i,j),coord(i+2,j-2))) && (prevent(coord(i+2,j-2),coord(i+1,j-1)))) {
    return true;
    // step two - if step one not taken, look for jumps
    for(var j=7;j>=0;j--) {
    for(var i=0;i<8;i++) {
    if (jump(i,j))
    return true;
    safe_from = null;
    // step three - if step two not taken, look for safe single space moves
    for(var j=0;j<8;j++) {
    for(var i=0;i<8;i++) {
    if (single(i,j))
    return true;
    // if no safe moves, just take whatever you can get
    if (safe_from != null) {
    move_comp(safe_from,safe_to);
    } else {
    message("You beat me!!");
    game_is_over = true;
    safe_from = safe_to = null;
    return false;
    function jump(i,j) {
    if (board[i][j] == -1.1) { 
    if (legal_move(coord(i,j),coord(i+2,j+2))) {
    move_comp(coord(i,j),coord(i+2,j+2));
    setTimeout("jump("+(i+2)+","+(j+2)+");",500);
    return true;
    } if (legal_move(coord(i,j),coord(i-2,j+2))) {
    move_comp(coord(i,j),coord(i-2,j+2));
    setTimeout("jump("+(i-2)+","+(j+2)+");",500);
    return true;
    } if (integ(board[i][j]) == -1) {
    if (legal_move(coord(i,j),coord(i-2,j-2))) {
    move_comp(coord(i,j),coord(i-2,j-2));
    setTimeout("jump("+(i-2)+","+(j-2)+");",500);
    return true;
    } if (legal_move(coord(i,j),coord(i+2,j-2))) {
    move_comp(coord(i,j),coord(i+2,j-2));
    setTimeout("jump("+(i+2)+","+(j-2)+");",500);
    return true;
    return false;
    function single(i,j) {
    if (board[i][j] == -1.1) {
    if (legal_move(coord(i,j),coord(i+1,j+1))) {
    safe_from = coord(i,j);
    safe_to = coord(i+1,j+1);
    if (wise(coord(i,j),coord(i+1,j+1))) {
    move_comp(coord(i,j),coord(i+1,j+1));
    return true;
    } if (legal_move(coord(i,j),coord(i-1,j+1))) {
    safe_from = coord(i,j);
    safe_to = coord(i-1,j+1);
    if (wise(coord(i,j),coord(i-1,j+1))) {
    move_comp(coord(i,j),coord(i-1,j+1));
    return true;
    } if (integ(board[i][j]) == -1) {
    if (legal_move(coord(i,j),coord(i+1,j-1))) {
    safe_from = coord(i,j);
    safe_to = coord(i+1,j-1);
    if (wise(coord(i,j),coord(i+1,j-1))) {
    move_comp(coord(i,j),coord(i+1,j-1));
    return true;
    } if (legal_move(coord(i,j),coord(i-1,j-1))) {
    safe_from = coord(i,j);
    safe_to = coord(i-1,j-1);
    if (wise(coord(i,j),coord(i-1,j-1))) {
    move_comp(coord(i,j),coord(i-1,j-1));
    return true;
    return false;
    function possibilities(x,y) {
    if (!jump(x,y))
    if (!single(x,y))
    return true;
    else
    return false;
    else
    return false;
    function prevent(end,s) {
    i = end.x;
    j = end.y;
    if (!possibilities(s.x,s.y))
    return true;
    else if ((integ(board[i-1][j+1])==-1) && (legal_move(coord(i-1,j+1),coord(i,j)))) {
    return move_comp(coord(i-1,j+1),coord(i,j));
    } else if ((integ(board[i+1][j+1])==-1) && (legal_move(coord(i+1,j+1),coord(i,j)))) {
    return move_comp(coord(i+1,j+1),coord(i,j));
    } else if ((board[i-1][j-1]==-1.1) && (legal_move(coord(i-1,j-1),coord(i,j)))) {
    return move_comp(coord(i-1,j-1),coord(i,j));
    } else if ((board[i+1][j-1]==-1.1) && (legal_move(coord(i+1,j-1),coord(i,j)))) {
    return move_comp(coord(i+1,j-1),coord(i,j));
    } else {
    return false;
    function wise(from,to) {
    i = to.x;
    j = to.y;
    n = (j>0);
    s = (j<7);
    e = (i<7);
    w = (i>0);
    if (n&&e) ne = board[i+1][j-1]; else ne = null;
    if (n&&w) nw = board[i-1][j-1]; else nw = null;
    if (s&&e) se = board[i+1][j+1]; else se = null;
    if (s&&w) sw = board[i-1][j+1]; else sw = null;
    eval(((j-from.y != 1)?"s":"n")+((i-from.x != 1)?"e":"w")+"=0;");
    if ((sw==0) && (integ(ne)==1)) return false;
    if ((se==0) && (integ(nw)==1)) return false;
    if ((nw==0) && (se==1.1)) return false;
    if ((ne==0) && (sw==1.1)) return false;
    return true;
    message("You may begin! Select a piece to move.");
    my_turn = true;
    // -->
    </SCRIPT>

    Well, you can get a free tutorial to Java at http://www.mindview.net/. It's the "Thinking In Java" book. You can download the whole book from that site, it's about a thousand pages. If you read that whole book, you'll know exactly where to start and probably how to finish it too.
    As a gimmie, think about it -- you'll have to remove all of the browser-detect code, since browser-detection is only done to determine which version of JavaScript is supported by the browser.

  • Java Applet won't load when a JavaScript variable "this.Document" is used.

    Hi,
    Creating a "this.Document" variable within JavaScript interferes with some versions of Java. So far it breaks on the following versions, using IE7 on Windows XP:
    * JRE 6.0 Update 7
    * JRE 6.0 Update 6
    * JRE 6.0 Update 5
    * JRE 6.0 Update 4
    [Due to time constraints JRE 6.0 to JRE 6.0 Update 3 were not tested]
    * JRE 5.0 Update 22
    [Due to time constraints JRE 5.0 Update 16 to JRE 5.0 Update 21 were not tested]
    * JRE 5.0 Update 15
    [Due to time constraints JRE 5.0 Update 1 to JRE 5.0 Update 14 were not tested]
    * JRE 5.0
    The following HTML demonstrates this problem when you have any of the above versions of Java installed:
    <html>
        <head>
            <title>Java Bug</title>
            <script type="text/javascript" language="javascript">
                this.Document = 'string'; // Remove this line to get it to work again
            </script>
        </head>
        <body style="background-color:black">
            <applet id="testVM" alt="Something is wrong. Java is not working."
                codebase="http://www.java.com/applet" code="testJava2_1/TestVMApplet"
                archive="TestVM2-test.jar" width="500" height="280">
                <param name="locale" value="en" />   
                <param name="titleSize" value="22" />
                <param name="subtitleSize" value="18" />   
            </applet>
        </body>
    </html>The page only displays a white box where the Java Applet should be. If you then remove the "this.Document" variable or simply rename it to something else then the applet loads without problems. Normally I would just use a different variable name but the variable name is placed within the Mootools JavaScript Framework and is not easily changed without forking my own project.
    Does anyone know why this happens and if it can be fixed without having to update to the latest version of Java?
    Thanks

    EJP wrote:
    'this.document' is a predefined variable that defines the URL source of the current page. If you are referring to the predefined variable that provides access to the Document Object Model then I believe you are mistaken, that is 'window.document' or just 'document'.
    EJP wrote:
    Your name either conflicts with that or is getting confused with it somewhere.The 'document' variable is a parent of the window object e.g. 'window.document' but my variable has the context of 'this'. That means 'this.document.URL' returns 'undefined' instead of the URL for the current page.
    JavaScript is also case sensitive so 'document.URL' is not the same as 'Document.URL', the last of which returns 'undefined'.
    If Java relealy was confusing my variable with the predfined one then I would expect the same behaviour if I were to use differnt variations of the variable. However the follwoing JavaScript doesnt affect the Applet in anyway:
    <script type="text/javascript" language="javascript">
        //this.Document = 'string'; // Remove this line to get it to work again
        this.document = 'string';
        document = 'string';
        Document = 'string';            
    </script>For some strange reason it only affects the Applet when 'this.Document' is used. Why would Java be affected in this way in the first instance? Even setting the 'scriptable' parameter to false doesn’t help:
    <param name="scriptable" value="false">Are there any other settings I am not aware of that could maybe prevent Java from loooking at the JavaScript?
    EJP wrote:
    Use another name.As I mentioned in my original post this is not easily done, I can edit the source code on my own site but the code still remains unchanged on the Mootools JavaScript Framework website.
    Thanks

  • JavaScript calls method on Java Applet-- Problem

    Hi all,
    I have a problem as following:
    I have a method on JavaScript calling a method on Java Applet. A method on JavaScript repeatedly retrieves data form the server , let's say; every 100 ms and it calls the method on Java to draw a graph(I use thread to call repaint()). The problem is, if I leave the applet site(or the site has lost the focus), the stop() will be called and I can't recieve data from JavaScript anymore. If I go back to the site, the applet starts, but the graph doesn't show the figure, as it supposes to show.
    how can I tell the browser doesn't call the stop() or there is another way to solve this problem?
    Thanks for all answers. CU.
    A-Pex

    my own fault.. it's not the browser or the applet.. It's my computer.. it's too old for this applet..
    Does anyone know, how to optimize the applet with thread? thanks..

  • JavaScript call to Java applet

    Sorry if this message get posted twice, but I haven't seen the 1st. I sent.
    I seem to have a problem with a form trying to call an applet. I hava a button like this:
    <input type=button value="Add" onClick="Nota.addRow('2','3','12.80','Cacahuates Mafer 1/2 kg.')">
    my Nota.addRow method is thisone:
    public void addRow (String idS, String qtyS, String priceS, String desc) {
    int id= Integer.parseInt (idS);
    int qty= Integer.parseInt (qtyS);
    float price= Float.parseFloat (priceS);
    remove (total);
    renglones[renglonCnt]= new Renglon (id,qty,price,desc);
    add (renglones[renglonCnt]);//<- This line is not adding the Row when i call it from JavaScript. Otherwise it works just fine...
    //total= Renglon.Total();
    //add (total);
    System.out.println("El id es: " + Integer.toString(id));
    System.out.println("La cantidad es: " + Integer.toString(qty));
    System.out.println("El precio es: " + Float.toString(price));
    System.out.println("La descripcion es: " + desc.toString());
    System.out.println("El precio del objeto es: " + Float.toString(renglones[renglonCnt].getTotal()));
    renglonCnt++;
    Altough my addRow works when I callit from a Nota object it doesn't when i call it from javascript.
    total is just a panel that you get from class Renglon.
    And Renglon is a Panel class too.
    I'll appreciate any help, thanks.
    Jeronimo

    Hey, that's really good news, does it actually adds the row to the applet and gets the new total?!
    Anyway, i tried 1.) (wich describes the applet quite well) and 2.) but still doesn't works for me. Also changed the "price" line...
    Im using:
    Navigator 4.72
    IE 5.50
    Netscape 6
    Here's the html code (the form):
    <form>
    <table border=5 WIDTH=500 align=center>
    <tr>
    <TD width=30%>
    <table border=1 width="100%" >
    <tr>
    <th WIDTH="20%"> Cantidad </th>
    <th WIDTH="26%"> Descripci&oacute;n </th>
    <th WIDTH="20%">Precio Unitario</th>
    <th WIDTH="20%"> Agregar </th>
    </tr>
    <tr>
    <td WIDTH="20%" align=center>
         <input size=2 name=cantidad maxlength=2>
         </td>
    <td WIDTH="26%">
         Cerveza Sol 600ml.
         </td>
    <td WIDTH="20%">
         $15.50
         </td>
    <td WIDTH="20%" align=center>
         <input type=button value="Add" onClick="document.Nota.addRow('1','12','15.50','Cerveza-Sol-600ml.')">
         </td>
    </tr>
    <tr>
    <td WIDTH="20%" align=center><input size=2 maxlength=2></td>
    <td WIDTH="26%">
         Cacahuates Mafer 1/2 kg.
         </td>
    <td WIDTH="20%">
         $12.80
         </td>
    <td WIDTH="20%" align=center>
         <!--<input type=button value="Add" onClick="Nota.addRow('2','3','12.80','Cacahuates Mafer 1/2 kg.')">
         -->
         <input type=button value="Test" onClick="alert (Nota)"
         </td>
    </tr>
    <tr>
    <td WIDTH="20%" align=center><input size=2 maxlength=2></td>
    <td WIDTH="26%"> </td>
    <td WIDTH="20%"> </td>
    <td WIDTH="20%" align=center>
         <input type=button value="Add">
         </td>
    </tr>
    <tr>
    <td WIDTH="20%" align=center><input size=2 maxlength=2></td>
    <td WIDTH="26%"> </td>
    <td WIDTH="20%"> </td>
    <td WIDTH="20%" align=center><input type=button value="Add"></td>
    </tr>
    </table>
    </td>
    <td width="40%">
    <applet name=Nota code=Nota.class width=350 height=250> </applet>
    </td>
    </tr>
    <tr>
    <td colspan=2 align=center>
    <input type=button value="Enviar Pedido">
    </td>
    </tr>
    </table>
    </form>
    Here's the Nota applet code:
    import java.awt.*;
    import java.applet.*;
    public class Nota extends Applet {
    private Renglon renglones[];
    private BarraTitulo titulo;
    private int renglonCnt;
    private Panel total;
    public void init () {
    setLayout (new GridLayout(12,1));
    renglonCnt=0;
    renglones= new Renglon [10];
    total= Renglon.Total();
    public void start () {
    String titulos[]= new String [4];
    titulos[0]="(-) Cantidad (+)";
    titulos[1]="Descripcion";
    titulos[2]="Precio Unitario";
    titulos[3]="Total";
    titulo= new BarraTitulo (titulos,12);
    add (titulo);
    add (total);
    public void addRow (String idS, String qtyS, String priceS, String desc) {
    int id= Integer.parseInt (idS);
    int qty= Integer.parseInt (qtyS);
    //float price= Float.parseFloat (priceS);
    float price= Float.valueOf (priceS).floatValue();
    remove (total);
    renglones[renglonCnt]= new Renglon (id,qty,price,desc);
    add (renglones[renglonCnt]);
    //total= Renglon.Total();
    //add (total);
    //THESE LINES SHOW EVERTHING WELL IN THE JAVA CONSOLE, BUT THESE ARE JUST FOR DEBUG. System.out.println("El id es: " + Integer.toString(id));
    System.out.println("La cantidad es: " + Integer.toString(qty));
    System.out.println("El precio es: " + Float.toString(price));
    System.out.println("La descripcion es: " + desc.toString());
    System.out.println("El precio del objeto es: " + Float.toString(renglones[renglonCnt].getTotal()));
    renglonCnt++;
    This is the Renglon class code:
    import java.awt.*;
    import java.awt.event.*;
    public class Renglon extends Panel implements ActionListener {
    private TextField qty, description, up, total;
    private Button more, less;
    private int cantidad, identificador;
    private float unitP;
    private String descripcion;
    static float elTotal= 0;
    static Panel totalP= new Panel();
    static Label c4tot= new Label();
    public Renglon () {
    this(1, 1, (float) 2.50, "Algun articulo");
    public Renglon (int id, int q, float pu, String desc) {
    identificador= id;
    cantidad= q;
    unitP= pu;
    descripcion= desc;
    elTotal+= cantidad * unitP;
    Panel addsub;
    setLayout (new GridLayout (1,4));
    addsub= new Panel();
    addsub.setLayout(new GridLayout(1,3));
    less= new Button ("<<");
    more= new Button (">>");
    less.addActionListener (this);
    more.addActionListener (this);
    Integer c= new Integer (cantidad);
    qty= new TextField (c.toString());
    description= new TextField (descripcion);
    Float x= new Float (unitP);
    up= new TextField ("$" + x.toString());
    Float t= new Float (getTotal());
    total= new TextField ("$" + t.toString());
    qty.setEditable (false);
    description.setEditable (false);
    up.setEditable (false);
    total.setEditable (false);
    addsub.add (less);
    addsub.add (qty);
    addsub.add (more);
    add (addsub);
    add (description);
    add (up);
    add (total);
    setVisible (true);
    public float getTotal () {
    return ((float) cantidad*unitP);
    public void actionPerformed (ActionEvent e) {
    if (e.getActionCommand().equals("<<")){
    cantidad--;
    elTotal-= unitP;
    if (cantidad < 0) {
    cantidad=0;
         elTotal+= unitP;
    } else {
    cantidad++;
    elTotal+= unitP;
    Float nuevoTot= new Float (getTotal());
    Integer c= new Integer (cantidad);
    qty.setText (c.toString());
    total.setText ("$" + nuevoTot.toString());
    Float et= new Float (elTotal);
    c4tot.setText("$" + et.toString());
    static public Panel Total () {
    totalP.setLayout (new GridLayout(1,4));
    Label c1,c2,c3;
    Float totalF= new Float (elTotal);
    c1= new Label("");
    c2= new Label("");
    c3= new Label("Total:");
    c4tot= new Label("$" + totalF.toString());
    totalP.add(c1);
    totalP.add(c2);
    totalP.add(c3);
    totalP.add(c4tot);
    totalP.setVisible(true);
    return (totalP);
    And just in case, this is the BarraTitulo class code:
    import java.awt.*;
    public class BarraTitulo extends Panel {
    public BarraTitulo (String [] titulos) {
    this (titulos,15);
    public BarraTitulo (String [] titulos, int size) {
    Label labels;
    Font ft= new Font("Serif",Font.BOLD, size);
    int length= titulos.length + 1;
    setLayout (new GridLayout (1,length));
    setFont (ft);
    for (int i=0; i< titulos.length; i++) {
    labels= new Label(titulos);
    add (labels);
    Thanx again for your time.
    Jeronimo

  • Forms Client Java Applet waiting several minutes

    Hello,
    We use Forms 10.1.2.0 and html/javascript/plsql applications.
    All forms applications are working but
    we have the problem that from time to time the client java applet must wait minutes until there is an answer from the forms-servlet (especially when there is high activity in the system).
    More than one user is working in the form with high activity - the applet sends a request
    over the network - after 4 minutes the result is shown and you can go on working
    without problems.
    So a lot of users think the application has crashed and terminate before.
    The applet shows no error messages.
    There is no sign that there is a lost connection between applet and servlet.
    It is not reproducible. That means you can work 2 hours and everything is ok
    or you work 5 minutes and you have to wait.
    network problems?
    firewall problems?
    do requests of the forms servlet to the database have minor priority on the application server
    than html/plsql requests?
    any ideas?

    when the problem occurs (user has to wait 3-4 minutes) we found in the log
    3 heartbeats from the forms client within 2 seconds ?
    after 3-4 minutes the forms client is ok (user can go on working)
    and the pings are every 2 minutes (like it is expected).
    The application.log file may contain duplicate posts requests with
    identical pragma header numbers, indicating that the client
    is resending
    requests due to network packet losses. Under normal circumstances,
    only the last Post request, terminating a Forms session,
    should contain
    a duplicate pragma header number.
    ...a network problem ?
    anyone else who had the same problem ?

  • Referencing a "locally installed" Java applet from a server-based HTML page

    How does one reference a "locally installed" Java applet from a server-based HTML page (i.e. via the applet, object, or embed tags)? I have seen references in documentation that this is possible, but I have not seen any examples. I have tried a few things, but nothing seems to be working.
    Some background...
    I'm working on a web site that aggregates Internet video. For many users, I would like the site to work "without" requiring Java to be installed (or any prompts, etc.). This version of the site allows users to stream videos directly over the Internet and does not require any sort of access to the local system.
    However, in addition, I have a download manager that can be installed on the local system. Currently, it's a Windows-based "service" that is always running in the background, downloading files, etc. (with plans to later support other OSes).
    My dilemma is trying to communicate between my web site running in the local browser (executing JavaScript code) and the download manager. I call this component the "gateway". I need the gateway to be able to do the following:
    1) Pass user credentials from the web browser UI to the download manager (so it can communicate with my servers).
    2) Check the status of downloaded videos
    3) Launch a local media player (such as Windows Media, QuickTime, etc.) (or perhaps tell the download manager to launch the media player).
    Under Windows XP, I have an ActiveX control that can do these things. It communicates with the download manager via reading/writing to a shared XML configuration file.
    Unfortunately, under Vista and IE7 Protected Mode, ActiveX controls have become very restricted and my gateway no longer works. As such, I am looking at using Java for the gateway (also giving me the additional benefits of supporting additional browsers and OSes).
    From my understanding, I believe I can created a "face-less" Java applet, whose methods can be called from JavaScript. Ideally, I'm thinking I could install the applet onto the local system at the same time the download manager is installed. This would give the applet the security permissions it needs to communicate with the download manager.
    Thanks for any help and suggestions!

    Hi,
    Put the .jar file and the .class file in the path mentioned in one of the aliases in the plsql.conf file like /images or create
    a seperate directory and create an alias like /applets "path" in the plsql.conf file.
    <html>
    <body>
    <applet code=com.chartapplet.chart.BarChartApplet
    codebase=/applets/
    archive=/applets/chart.jar width=300 height=200>
    <param name=background value="white">
    </body>
    </html>
    Hope this helps.
    Thanks,
    Sharmila

Maybe you are looking for

  • How can i find my icloud ID

    how can i find my icloud ID ?  i had upgraded my iphone4 to IOS7 and created an Icould ID, after couple of months my phone was restored and when i am trying to  use my iphone4 it is asking me for icloud ID please see the exact message in bracket (Thi

  • An error occurred accessing a data source.

    Hi, I have seen many posts talking about this error but still i am facing the same issue. The process i have followed is: 1) created infopath form with receive data connection to SQL DB with plain username/pwd 2) placed the repaeating table of receiv

  • How can I write to a file from a livecycle designed PDF?

    I am producing a PDF in Livecycle designer and would like to write a sub-set of data from the document. I have tried methods such as exportData() but this exports everything which i don't need. I have seen another method which is to attach a file and

  • Camera Issue without flash on.

    Ok, I have let's say some teething problems with my iphone 4s. I have the battery issue where sometimes it doesnt charge to 100% (although my battery life is good), I also have the annoying background interference when i make a call and 3g is turned

  • Memory Leak while using -Xrunhprof option in Linux OS

    While using the follwing option in my application there is memory leak in JVM in Linux OS. -Xrunhprof:heap=all,cpu=times,monitor=y,file=/home/gemini/dilip/www2.log,thread=yIs this a bug ??