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 4 of 4

Thread: Passing a value from applet to java script

  1. #1
    Junior Member
    Join Date
    Feb 2014
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Passing a value from applet to java script

    Hello,

    I have a java application in which when starting it a map is opened and a screen is captured. The capturing is in certain time interval. I want to enable the user to change the interval for the automatic capturing the map. I placed a text box in a JPanel. I want to pass the value which was entered in it to the html page which opens a Google map. Since I am new in java programming, I found that I can do it by using applets. I made an applet, and tried to call it in the html file. But now instead of opening the map file in a browser, it opens very quickly only black window.

    Here is my applet:

    package cege.ui;

    import java.applet.Applet;
    import java.io.IOException;
    import cege.ui.GuiMain;

    public class AppletTInterval extends Applet {
    private int TimeInterval=0;

    public void init() {
    try {
    TimeInterval=GuiMain.TRAFFIC_REFRESH_RATE;
    }
    catch (Exception e) {
    e.printStackTrace();
    }
    }

    public int getTimeInterval () {
    return TimeInterval;
    }
    }


    and the code in the html file where I try to call the applet, i.e. to pass the value which is returned by the applet is:

    <script src=
    <!--"https://www.java.com/js/deployJava.js"></script>
    <script>

    var attributes = { id:'AppletTInterval',
    code:'cege.ui.AppletTInterval', width:1, height:1} ;
    var parameters = { jnlp_href: 'AppletTInterval.jnlp'} ;
    deployJava.runApplet(attributes, parameters, '1.6');
    </script>

    <script type="text/javascript">

    TRAFFIC_REFRESH_RATE = AppletTInterval.getTimeInterval();

    if(TRAFFIC_REFRESH_RATE = 0)
    {
    var TRAFFIC_REFRESH_RATE = 20000;
    }
    else
    {
    TRAFFIC_REFRESH_RATE = AppletTInterval.getTimeInterval()
    }

    Can anybody help me please, what should I do, where I make a mistake, or can I use this way to pass a value from the java class file (from the JTextField into the html file?

    Thank you in advance.


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    6,349
    My Mood
    Mellow
    Thanks
    254
    Thanked 784 Times in 769 Posts

    Default Re: Passing a value from applet to java script

    Welcome to the Forum! Please read this topic to learn how to post code correctly and other useful tips for newcomers.

  3. #3
    Junior Member
    Join Date
    Feb 2014
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Passing a value from applet to java script

    I solved it without applet. Thanks anyway.

  4. #4
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    6,349
    My Mood
    Mellow
    Thanks
    254
    Thanked 784 Times in 769 Posts

    Default Re: Passing a value from applet to java script

    That's cheating, and it's not what you asked for help with. Next time, if there is a next time, state your problem and the solution set more clearly.

Similar Threads

  1. [SOLVED] Passing parameters to an Applet
    By Fabgio in forum Java Applets
    Replies: 3
    Last Post: July 26th, 2013, 06:14 PM
  2. passing variables from java applet to php
    By sabertooth in forum Java Networking
    Replies: 2
    Last Post: April 19th, 2013, 01:44 AM
  3. passing parameters from Applet to JSP
    By haythem in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 4th, 2013, 02:06 AM
  4. Replies: 2
    Last Post: September 4th, 2012, 04:04 PM
  5. Downloading web page with java script enabled through Java
    By mashimaro in forum Java Networking
    Replies: 1
    Last Post: November 13th, 2010, 09:28 PM

Tags for this Thread