CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 2000
    Location
    singapore
    Posts
    6

    applet not running

    Something is wrong but dont know why.
    In the html, the applet is shown as follows:

    <applet code="DigitalThreads.class" width=100 height=25>
    <param name="DATE" value="957539317">
    </applet>

    My program for the applet is as follows:
    long fromcgi = Long.parseLong(getParameter("DATE"));
    long fromcgi1 = fromcgi * 1000 ;
    Font theFont = new Font("TimesRoman", Font.BOLD, 20);
    Color mycolor = new Color(197,180,89);
    Date theDate;
    Thread runner;

    public void start() {
    if (runner == null); {
    runner = new Thread(this);
    runner.start();
    }
    }

    public void stop() {
    if (runner != null) {
    runner.stop();
    runner = null;
    }
    }

    public void run() {
    while (true) {
    theDate = new Date();
    repaint();
    try { Thread.sleep(1000); }
    catch (InterruptedException e) { } }

    }

    public void paint(Graphics g) {
    g.setFont(theFont);
    setBackground(mycolor);
    setForeground(Color.black);
    long duration = (theDate.getTime() - fromcgi1)/1000;
    String durationString = "Run out time" ;
    if (duration < (60 * 60 * 24 ) ) {
    long hour = duration/(60 * 60);
    long min = duration % (60 * 60);
    long minx = min/60 ;
    long secs = min % 60 ;
    durationString = Long.toString(hour)+ ":" +Long.toString(minx)+ ":" + Long.toString(secs) ;
    }
    g.drawString(durationString,5,17);
    }
    }



    Notice The first line on my applet programing is as follows:
    long fromcgi = Long.parseLong(getParameter("DATE"));

    But the applet wont run when I include the above line.
    It was running before I included the line.

    Any ideas ?





  2. #2
    Join Date
    Dec 1999
    Location
    Chonghe, Taipei County, Taiwan, R.O.C.
    Posts
    231

    Re: applet not running

    You may have to getParameter in the method init() which is the method called by the browser.
    The browser may call init() and start() when the applet is executed.
    good luck,
    Alfred Wu


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured