Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Java
  4. How to pass a value from Java Applet code to HTML page

How to pass a value from Java Applet code to HTML page

Scheduled Pinned Locked Moved Java
javajavascripthtmlgraphicshelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Prathviraj080
    wrote on last edited by
    #1

    I have an application where I need to send the values from java applet code to html page. Please help me to send the values from java code to HTML page(may be using javascript) My java code is,

    public class Calc extends Applet
    {

    public int tot = 0;
    public void paint(Graphics g) 
    {
    int M1 = Integer.parseInt(this.getParameter("m1"));
    int M2 = Integer.parseInt(this.getParameter("m2"));
    int M3 = Integer.parseInt(this.getParameter("m3"));
    int M4 = Integer.parseInt(this.getParameter("m4"));
    int M5 = Integer.parseInt(this.getParameter("m5"));
    int M6 = Integer.parseInt(this.getParameter("m6"));
    tot=M1+M2+M3+M4+M5+M6;
    this.setParameter("tot",Integer.toString(tot));
    g.drawString(Integer.toString(tot), 10, 10);
    }
    

    }

    S 1 Reply Last reply
    0
    • P Prathviraj080

      I have an application where I need to send the values from java applet code to html page. Please help me to send the values from java code to HTML page(may be using javascript) My java code is,

      public class Calc extends Applet
      {

      public int tot = 0;
      public void paint(Graphics g) 
      {
      int M1 = Integer.parseInt(this.getParameter("m1"));
      int M2 = Integer.parseInt(this.getParameter("m2"));
      int M3 = Integer.parseInt(this.getParameter("m3"));
      int M4 = Integer.parseInt(this.getParameter("m4"));
      int M5 = Integer.parseInt(this.getParameter("m5"));
      int M6 = Integer.parseInt(this.getParameter("m6"));
      tot=M1+M2+M3+M4+M5+M6;
      this.setParameter("tot",Integer.toString(tot));
      g.drawString(Integer.toString(tot), 10, 10);
      }
      

      }

      S Offline
      S Offline
      Sherin_Mathew
      wrote on last edited by
      #2

      The sample HTML file The listing below shows the source code for the sample HTML file we created for this article, including the applet tag shown.We name this file AppletParameterTest.html.

      Java applet example - Passing applet parameters to Java applets

      The ParamTest.java file So far we've seen to create the HTML code that (1) invokes a Java applet using an applet tag, and (2) passes parameters to the applet. Next, let's look at the Java applet code needed to read the parameters being passed to it. The next listing shows the Java code for the ParamTest.java file.

      import java.applet.*;
      import java.awt.*;

      public class AppletParameterTest extends Applet {

      public void paint(Graphics g) {

        String myFont   = getParameter("font");
        String myString = getParameter("string");
        int mySize      = Integer.parseInt(getParameter("size"));
      
        Font f = new Font(myFont, Font.BOLD, mySize);
        g.setFont(f);
        g.setColor(Color.red);
        g.drawString(myString, 20, 20);
      

      }
      }

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups