Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can have full communication between your Applet and any javascript method on the page. Kyle has a good post demonstrating how the Javascript can call the applet and request the text value. However, I presume you want the HTML Textfield to update with each mouse click, meaning the applet needs to communicate with the page. I would modify your javascript to something like this:</p> <pre><code>var activeTextArea = null; $('textarea, input').click(function() { $(this).dasher(); activeTextArea = this; }); function updateText(text) { // Careful: I think textarea and input have different // methods for setting the value. Check the // jQuery documentation $(activeTextArea).val(text); } </code></pre> <p>Assuming you have the source for the applet, you can have it communicate with the above javascript function. Add this import:</p> <pre><code>import netscape.javascript.JSObject; </code></pre> <p>And then, in whatever onClick handler you have for the mouse clicks, add:</p> <pre><code>// After the Applet Text has been updated JSObject win = null; try { win = (JSObject) JSObject.getWindow(Applet.this); win.call("updateText", new Object[] { textBox.getText() }); } catch (Exception ex) { // oops } </code></pre> <p>That will update the text each time that chunk of code is called. If you do NOT have access to the applet source, things get trickier. You'd need to set some manner of javascript timeout that constantly reads the value from the applet, but this assumes the applet has such a method that returns the value of the textbox.</p> <p>See Also: <a href="http://java.sun.com/products/plugin/1.3/docs/jsobject.html" rel="noreferrer">http://java.sun.com/products/plugin/1.3/docs/jsobject.html</a></p> <p><strong>Update</strong> Modifying the applet is your best shot since that is where any event would be triggered. For example, if you want the HTML TextField to change on every click, the click happens in the applet which would need to be modified to trigger the update, as described above. Without modifying the applet, I see two options. Option #1 uses a timer: </p> <pre><code>var timer; var activeTextArea; $('textarea, input').click(function() { $(this).dasher(); activeTextArea = this; updateText(); } function updateText() { // Same warnings about textarea vs. input $(activeTextArea).val($('#appletId')[0].getCurrentEditBoxText()); timer = setTimeout("updateText()", 50); } function stopUpdating() { clearTimeout(timer); } </code></pre> <p>This is similar to the code above except clicking on a text area triggers the looping function <code>updateText()</code> which will set the value of the HTML text field to the value of the Applet text field every 50ms. This will potentially introduce a minor delay between click and update, but it'll be small. You can increase the timer frequency, but that will add a performance drain. I don't see where you've 'hidden' the applet, but that same function should call <code>stopUpdating</code> so that we are no longer trying to contact a hidden applet. </p> <p>Option #2 (not coded)</p> <p>I would be to try and capture the click in the Applet as it bubbles through the HTML Dom. Then, you could skip the timer and put a <code>click()</code> behavior on the Applet container to do the same update. I'm not sure if such events bubble, though, so not sure if this would work. Even if it did, I'm not sure how compatible it would be across browsers.</p> <p>Option #3</p> <p>Third option is to not update the HTML text field on every click. This would simply be a combination of Kyle's and my posts above to set the value of the text field whenever you 'finish' with the applet.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload