Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5946777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:52:15+00:00 2026-05-22T16:52:15+00:00

I have been working with a Java applet which is an applet that helps

  • 0

I have been working with a Java applet which is an applet that helps to write using only a mouse. For my case, I am trying to incorporate this into my webiste project as follows:

When the user clicks on any input element (textbox/textarea) on the page, this JAVA applet loads on the webpage itself. In the screenshot of the JAVA applet seen below, the user points to an alphabet to and the corresponding text gets written in the text box of the applet.

enter image description here

Now what I am trying to do is to get this text from the TextBox of the applet to the input element on the webpage. I know that this needs an interaction between the Java and JavaScript, but not being a pro, I really do not have the catch. Here’s the Java applet and the code I have written.

Java applet and jQuery code (298kB): http://bit.ly/jItN9m

Please could somebdoy help for extending this code.
Thanks a lot!

Update

I searched somewhere and found this -> To get the text inside of Java text box, a getter method in the Applet to retrieve the text:

public class MyApplet extends JApplet {
  // ...
  public String getTextBoxText() { return myTextBox.getText(); }
}

In the JQuery code, the following lines are to be added I think:

var textBoxText = $("#applet-id")[0].getTextBoxText();
//Now do something with the text

For the code of the applet, I saw a GNOME git page here. The getText call already exists — look at the bottom of this file: http://git.gnome.org/browse/dasher/tree/java/dasher/applet/JDasherApplet.java

I’d need to call ‘getCurrentEditBoxText’ but when should this method ‘getCurrentEditBoxText’ be called?
In my case, I would probably have to do it when the user clicks in a new input control etc.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T16:52:15+00:00Added an answer on May 22, 2026 at 4:52 pm

    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:

    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); 
    }
    

    Assuming you have the source for the applet, you can have it communicate with the above javascript function. Add this import:

    import netscape.javascript.JSObject;
    

    And then, in whatever onClick handler you have for the mouse clicks, add:

    // 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
    }
    

    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.

    See Also: http://java.sun.com/products/plugin/1.3/docs/jsobject.html

    Update 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:

    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);
    }
    

    This is similar to the code above except clicking on a text area triggers the looping function updateText() 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 stopUpdating so that we are no longer trying to contact a hidden applet.

    Option #2 (not coded)

    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 click() 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.

    Option #3

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working in Java/J2ee projects, in which I follow the Maven structure.
I have been working on a Java project in which the reports will be
So I have been working on a 2 player Tic-Tac-Toe game in java that
I have been working on a java application that has a connection to a
I have been working with a 3rd party java based REST webservice, that returns
I have been working with Java a couple of years, but up until recently
I have been working on a Java project for a class for a while
I have been working on Eclipse recently. I am fairly new to java programming,
Would a LINQ for java be a useful tool? I have been working on
I have been working with Visual Studio (WinForm and ASP.NET applications using mostly C#)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.