Starting Java applet with parameters

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rick

    Starting Java applet with parameters

    Hi,

    what I'd like to do is to use a java applet on my website. But it needs some
    information so I was thinking about giving parameters when the applet
    starts. But is this possible? When I try code like this in Netbeans the
    applet will give errors while starting.
    public MyApplet( int argC, String args[] )
    {
    // the constructor of the applet
    }
    How to use startup arguments? Or if this is not possible, are their other
    good ways to send data to the applet( or let the applet get data from the
    website, the data is a long string inside a textbox).

    Greetings,
    Rick




  • Silvio Bierman

    #2
    Re: Starting Java applet with parameters


    "Rick" <aso3rick@hotma il.com> wrote in message
    news:3f8bbe38$0 $58712$e4fe514c @news.xs4all.nl ...[color=blue]
    > Hi,
    >
    > what I'd like to do is to use a java applet on my website. But it needs[/color]
    some[color=blue]
    > information so I was thinking about giving parameters when the applet
    > starts. But is this possible? When I try code like this in Netbeans the
    > applet will give errors while starting.
    > public MyApplet( int argC, String args[] )
    > {
    > // the constructor of the applet
    > }
    > How to use startup arguments? Or if this is not possible, are their other
    > good ways to send data to the applet( or let the applet get data from the
    > website, the data is a long string inside a textbox).
    >
    > Greetings,
    > Rick
    >
    >
    >
    >[/color]

    Rick,

    You must add the parameters in the <applet> tag, something like

    <applet ...>
    <param name="p1" value="v1"/>
    <param name="p2" value="v2"/>
    </applet>

    and access them through Applet.getParam eter(String)

    Regards,

    Silvio Bierman


    Comment

    • Rick

      #3
      Re: Starting Java applet with parameters

      Ok, got that part. But how and where to catch them in the applet? If I add
      some parameters to the applet contructor it crashes(compili ng in Netbeans)
      and if I put them in the init() routine the init won't be executed.

      Greetings,
      Rick


      Comment

      • Me

        #4
        Re: Starting Java applet with parameters

        Check the API documentation for Applet. The class has a member function that
        will do that.

        Rich

        in article 3f8d2bf2$0$5870 2$e4fe514c@news .xs4all.nl, Rick at
        aso3rick@hotmai l.com wrote on 10/15/03 7:15 AM:
        [color=blue]
        > Ok, got that part. But how and where to catch them in the applet? If I add
        > some parameters to the applet contructor it crashes(compili ng in Netbeans)
        > and if I put them in the init() routine the init won't be executed.
        >
        > Greetings,
        > Rick
        >
        >[/color]

        Comment

        Working...