Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 17 of 17

Thread: How can I access the feilds in java applet?

  1. #1
    Junior Member
    Join Date
    Apr 2013
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How can I access the feilds in java applet?

    Hello,

    I am a new poster here. I really don't have much experience with Java, but I have encountered a problem and it looks like I'm going to need to familiarize myself with it quickly.

    Basically my question is how I could access the fields in a Java applet, more specifically to automatically input values? Could it be done through DOM or some other way?

    To provide a little more background on my problem, I am currently working on a program using VB.NET which will have an embedded browser that will direct the user to a Federal regulatory agency. Currently our HQ employees are accessing this site and manually typing a large number of values to submit to the agency. My hope is to automate this process with my program. The user will be able to select excel files through the winform and it will automatically pull the data from the files and populate the fields in the online form. .NET makes it very easy to access fields and assign values in general HTML so it looked like this project would be very simple. But unfortunately I discovered that the specific forms to submit our data are embedded within a Java applet, something I know very little about. So this complicates things a bit, but I'm hoping that someone may have some experience with this and could provide some sort of way to access/manipulate fields in a Java applet.

    If any more information is needed I'd be happy to provide it!

    Thanks,
    Michael


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: How can I access the feilds in java applet?

    way to access/manipulate fields in a Java applet.
    Are you writing a java class that will be part of a program that has a java applet class in it?

    If not, I don't know of an easy way for one program to get values being displayed by another program.

    If you can change the applet code there used to be ways for javascript and the java code in an applet to call each others methods.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Apr 2013
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How can I access the feilds in java applet?

    Quote Originally Posted by Norm View Post
    Are you writing a java class that will be part of a program that has a java applet class in it?

    If not, I don't know of an easy way for one program to get values being displayed by another program.

    If you can change the applet code there used to be ways for javascript and the java code in an applet to call each others methods.
    As of now I have done nothing, I tried (unsuccessfully) to get the field ID's in order to see if I could perhaps still use my "Setattribute" command. But I really don't know much about Java.

    And I don't belive that I can alter the applet code, this is an applet that's embedded within a federal agency website. I was just hoping to assign values to the fields.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: How can I access the feilds in java applet?

    If you don't own the applet code then it will be very hard to enter data into its fields.

    The Robot class can programatically operate the mouse and keyboard.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Apr 2013
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How can I access the feilds in java applet?

    That's what I was afraid of... I've considered a robot of some sort to move through but I don't think it would be worth it at that point.

    I was just really hoping that there was some way to modify the attribute of a field like you can do so easily within HTML. Otherwise I may just have to scrap the project unless you could think of any other way that could make my goal acheivable.

  6. #6
    Junior Member
    Join Date
    Apr 2013
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How can I access the feilds in java applet?

    I have been able to obtain the Java applet code, by having this could I now somehow enter data into the applet fields?

  7. #7
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: How can I access the feilds in java applet?

    What do you mean by a field? Is it an input area on a GUI like a textfield presents?
    Data can be displayed in a textfield by getting a reference to the instance of the textfield and calling its methods.
    How is applet code executed? Is it loaded by a browser in an html page? How would the applet get the data to put in its textfields?
    If you don't understand my answer, don't ignore it, ask a question.

  8. #8
    Junior Member
    Join Date
    Apr 2013
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How can I access the feilds in java applet?

    Yes that is what I mean by field, essentially multiple textboxes for data input...

    Do you how I would go about getting a reference to the instance in the textfield? Unfortunately I do not know much about Java, I came into this project thinking I would be populating simple html fields which is easy through .NET.

    And yes, it is loaded by a browser within an html page. I could gladly provide the html code that loads the applet and any of the applet code if it would help. Right now the data is input manually by being typed into each textfield.

  9. #9
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: How can I access the feilds in java applet?

    I do not know much about Java,
    Then you will need to learn how to write java code. It could be several months before you would even know if your project is possible.

    How is the applet's new code going to get the data it wants?
    If you don't understand my answer, don't ignore it, ask a question.

  10. #10
    Junior Member
    Join Date
    Apr 2013
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How can I access the feilds in java applet?

    Well my plan was never to change the applet code, I was just wondering if there's any way to expose the fields in order to automate an input process.

    Although this is clearly quite different from html, I was thinking along the lines of how you'd enter data into a html field by setting the value attribute to your input string.

    But if there's no simple way to do this I think I'll just go with a robot design that tabs through the textboxes and simulates the data entry. I was just thinking it would be more robust to address the fields directly, if this was even possible...

  11. #11
    Junior Member
    Join Date
    Apr 2013
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How can I access the feilds in java applet?

    Well my plan was never to change the applet code, I was just wondering if there's any way to expose the fields in order to automate an input process.

    Although this is clearly quite different from html, I was thinking along the lines of how you'd enter data into a html field by setting the value attribute to your input string.

    But if there's no simple way to do this I think I'll just go with a robot design that tabs through the textboxes and simulates the data entry. I was just thinking it would be more robust to address the fields directly, if this was even possible...

  12. #12
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: How can I access the feilds in java applet?

    Where would your code execute and how would it be related to a java applet executing in the jvm controlled by a browser?

    The Robot class's execution would be completely external to the applet.
    If you don't understand my answer, don't ignore it, ask a question.

  13. #13
    Junior Member
    Join Date
    Apr 2013
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How can I access the feilds in java applet?

    The code is being executed within a Winform application that pulls the desired data from an excel spreadsheet and outputs it to the applet..

    And yes, if I incorporate some sort of robot function I'm aware it's external. That's just my backup plan if I can't address the fields in the applet.

  14. #14
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: How can I access the feilds in java applet?

    A specially written applet can communicate with javascript code running in the html page the applet is located in.
    If you don't understand my answer, don't ignore it, ask a question.

  15. #15
    Junior Member
    Join Date
    Apr 2013
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How can I access the feilds in java applet?

    That would be ideal, and this could be incorporated into a winform based on the .NET framework?

  16. #16
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: How can I access the feilds in java applet?

    I don't know what winform is or anything about .NET.

    Here's an applet I wrote a long time ago that communicates with some javascript:
    Way Points
    If you don't understand my answer, don't ignore it, ask a question.

  17. #17
    Junior Member
    Join Date
    Apr 2013
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How can I access the feilds in java applet?

    Thanks, I'll do some investigating and tinkering and see what I can do..

Similar Threads

  1. how i can display ms access table in an java applet
    By munnaf in forum Java Applets
    Replies: 2
    Last Post: August 9th, 2012, 06:37 PM
  2. Problem With Applet Connecting With Microsoft Access Database
    By Saurabh Mittal in forum What's Wrong With My Code?
    Replies: 1
    Last Post: June 29th, 2011, 10:43 AM
  3. Java Web Start app exiting with access denie (java.lang.RuntimePermission
    By sonaljain in forum What's Wrong With My Code?
    Replies: 2
    Last Post: June 13th, 2011, 08:43 PM
  4. Created simple game applet but wanting it to access a DSN on the server
    By hirsty in forum What's Wrong With My Code?
    Replies: 7
    Last Post: April 21st, 2011, 03:11 AM
  5. Default Access (package access) confusion
    By gauravrajbehl in forum Java Theory & Questions
    Replies: 1
    Last Post: November 18th, 2009, 04:11 AM

Tags for this Thread