How to pass values from HTML page to java applet?

前端 未结 2 1914
孤独总比滥情好
孤独总比滥情好 2020-12-10 20:56

I have tried passing values using javascript like below



        
2条回答
  •  不思量自难忘°
    2020-12-10 21:15

    Source from this article

    For example: This is your applet codes:

    import java.applet.*;    
    import java.awt.*; 
    
    public class DrawStringApplet extends Applet {
    
      private String defaultMessage = "Hello!";
    
      public void paint(Graphics g) {
    
        String inputFromPage = this.getParameter("Message");
        if (inputFromPage == null) inputFromPage = defaultMessage;
        g.drawString(inputFromPage, 50, 25);
    
      }
    
    }
    

    Then in HTML:

    
    
     Draw String 
    
    
    
    This is the applet:

    This page will be very boring if your browser doesn't understand Java.

    Notice: DrawStringApplet is you applet name; Message is a parameter sent to applet; Applet will then display: Howdy, there! as a result.

提交回复
热议问题