13 Replies - 2479 Views - Last Post: 17 October 2005 - 11:59 PM Rate Topic: -----

#1 Lowrie  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 15
  • Joined: 14-July 05

HTML to Java Applet

Post icon  Posted 14 October 2005 - 04:01 PM

i would like to convert my java code into HTML webpage, i dont know how though...
i know its got somthing to do with <applet> and <objects> but i dont know where to stick the java code, and where to stick these applets, and what the applets actually look like... please somone help :crazy:
Is This A Good Question/Topic? 0
  • +

Replies To: HTML to Java Applet

#2 Rk47  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 27
  • Joined: 11-October 05

Re: HTML to Java Applet

Posted 14 October 2005 - 04:59 PM

Write the HTML code using whatever IDE you are using to compile java.
At the Applet Code in the body of the HTML, type in the name of teh class file.

<Html>
<Head>
<Title>Java Example</Title>
</Head>

<Body>
<Applet Code="Applet.class" width=x Height=y>
</Applet>
</Body>
</Html>
Was This Post Helpful? 0
  • +
  • -

#3 Lowrie  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 15
  • Joined: 14-July 05

Re: HTML to Java Applet

Posted 15 October 2005 - 09:38 AM

tryed that and i got this error
Loading Java Applet Faild

any idea what i did wrong?
Was This Post Helpful? 0
  • +
  • -

#4 skyhawk133  Icon User is offline

  • Head DIC Head
  • member icon

Reputation: 1866
  • View blog
  • Posts: 20,278
  • Joined: 17-March 01

Re: HTML to Java Applet

Posted 15 October 2005 - 09:53 AM

Are your HTML file and the class file in the same directory?
Was This Post Helpful? 0
  • +
  • -

#5 Lowrie  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 15
  • Joined: 14-July 05

Re: HTML to Java Applet

Posted 15 October 2005 - 10:12 AM

yes, if that means in the same folder
Was This Post Helpful? 0
  • +
  • -

#6 Rk47  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 27
  • Joined: 11-October 05

Re: HTML to Java Applet

Posted 15 October 2005 - 06:43 PM

Try adding <hr> below body and the the Applet code. And <hr> just below </applet> . Change the name of yer html file to the same name as your class file. I dont know if tht really matters or not. It works fine for me
Was This Post Helpful? 0
  • +
  • -

#7 Lowrie  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 15
  • Joined: 14-July 05

Re: HTML to Java Applet

Posted 16 October 2005 - 05:15 AM

<html>
<head>
<title>
The countdown applet
</title>
</head>
<body>
<h2>
Here is the countdown applet
</h2>
<hr>
<applet code="http://lowrie.50webs.com/countdown.class" width="1000" height="800">
</applet>
<hr>
</body>
</html>

thats the code, and that dosnt work....
Was This Post Helpful? 0
  • +
  • -

#8 1lacca  Icon User is offline

  • code.rascal
  • member icon

Reputation: 44
  • View blog
  • Posts: 3,822
  • Joined: 11-August 05

Re: HTML to Java Applet

Posted 16 October 2005 - 05:21 AM

Is your Java code subclassing the (J)Applet class? You can not use ordinary Java code as an applet.
Was This Post Helpful? 0
  • +
  • -

#9 Lowrie  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 15
  • Joined: 14-July 05

Re: HTML to Java Applet

Posted 16 October 2005 - 10:37 AM

import java.util.*;
import java.awt.*;
import java.applet.*;
import java.net.*;
import java.text.*;
import javax.swing.*;

public class countdown extends Applet implements Runnable
{
  private URL dest;
  private Date theDate = new Date();
  private String saying, font;
  private String path = "";
  private int i = 0;
  private int daylight = 0;
  private int tSec = 0;
  private int factor = 0;
  private  int second = theDate.getSeconds();
  private  int minute = theDate.getMinutes();
  private  int hour = theDate.getHours();
  private  int day = theDate.getDate();
  private  int month = theDate.getMonth() + 1;
  private  int year = theDate.getYear();
  private  int  this_tz_offset = theDate.getTimezoneOffset();
  private String thePath = "";
  private Thread timer = null;
  private ImageIcon theImage[] = new ImageIcon[14];
  private int lastsec = 0;
  private int totalSec = 0;
  private int theTime = 0;
  private int days_in_month[][] = { {31,29,31,30,31,30,31,31,30,31,30,31},
                          {31,28,31,30,31,30,31,31,30,31,30,31},
                          {31,28,31,30,31,30,31,31,30,31,30,31},
                          {31,28,31,30,31,30,31,31,30,31,30,31}};
   
  private int t_hrs, t_mins, t_secs, t_month, t_day, t_year ,t_daylight, tz_offset;
  private int s, rDays=0, rHours=0, rMinutes=0, rSecs=0;
  private int rYear=0, rMonth=0, rDay=0, rHour=0, rMinute=0, rSecond=0;
  private boolean tminus;
  private int days_in_year[] = {366,365,365,365};
  private int x_loc=5, y_loc= 5;
  private int colon_space = 7;
  private int dead_space = 9;
  private int digit_space = 15;
  private int base_today = 0;
  private int base_target = 0;
  private String param = "";
                                          
public void init()
{

        //.Get parameters from html <applet> tag.//
        try
        {
                saying = getParameter("text");
                path = getParameter("path");
                param = getParameter("dest");
                font = getParameter("font");
                try {
                        dest = new URL (getDocumentBase(), param);
                } catch(MalformedURLException mal) {
                        System.out.println("Malformed URL: Check Applet tag. ");
                }

                param = getParameter ("YEAR");   
                t_year = Integer.parseInt (param);

                param = getParameter ("MONTH");
                t_month = Integer.parseInt (param);

                param = getParameter ("DAY");
                t_day = Integer.parseInt (param);

                param = getParameter ("HOUR");
                if (param != null) {
                        t_hrs = Integer.parseInt (param);
                } else {
                        t_hrs = 0;
                }
        
                param = getParameter ("MINUTE");
                if (param != null) {
                        t_mins = Integer.parseInt (param);
                } else {
                        t_mins = 0;
                }

                param = getParameter ("SECOND");
                if (param != null) {
                        t_secs = Integer.parseInt (param);
                } else {
                        t_secs = 0;
                }
        
                param = getParameter ("TIMEZONE");
                if (param != null)
                        tz_offset = Integer.parseInt (param);
                else
                        tz_offset = 0;
                        
                param = getParameter ("DAYLIGHT");
                if (param != null) {
                        t_daylight = Integer.parseInt (param);
                } else {
                        t_daylight = 0;
                }
        } catch (Exception e)
        {
           return;
        }
                
        // Load the digit images.//
        for (int i = 0; i <= 9; i++)
        {
           theImage[i] = new ImageIcon(path + i + font + ".gif");
        }

        //.Load the colon image.//
        theImage[10] = new ImageIcon(path + "c_" + font + ".gif");

        //.Load the t-minus image.//
        theImage[11] = new ImageIcon(path + "tm_" + font + ".gif");

        //.Load the t-plus image.//
        theImage[12] = new ImageIcon(path + "tp_" + font + ".gif");

        //.Load the spacer image.//
        theImage[13] = new ImageIcon(path + "b_" + font + ".gif");

  //.The array "days_in_month[]" is used to keep track of the # of days in a month.//
  //.It is also used to keep track of the leap year.// 
  //.If the year is 1996 and the month is 2, then 1996 mod 4 = 0.//
  //.so days_in_month[0][2-1] = 29. 29 is used for the math.//


  //.The array "days_in_year[]" is used to keep track of the leap year.//
  //.If the year is 1996, then 1996 mod 4 = 0, and 366 would be used.//
  //.in the computation.//
 
  //.Leap years are evenly mod(ed).// 

  //.Calculate number of seconds from 00:00:00 Jan 1, 1990 until target.// 
  
  factor = 24 * 60 * 60;
  base_target += t_secs;
  base_target += t_mins * 60;
  base_target += t_hrs * 60 * 60;
  base_target += (t_day-1) * factor;
  for (i=1; i<t_month; i++)
  {
     base_target += days_in_month[t_year % 4][i-1] * factor;
  }

  base_target += tz_offset * 60;
  
  for (i=1970; i<t_year; i++)
  {
     base_target += days_in_year[i % 4] * factor;
  }
  if (t_daylight == 1){base_target -= 3600;}
  // calculate number of seconds from 00:00:00 Jan 1, 1990 until today 
    year += 1900;
    daylight = 0;
    base_today += second;
//    theTime += second;
    base_today += minute * 60;
//    theTime += minute * 60;
    base_today += hour * 60 * 60;
//    theTime += hour * 60 * 60;
    base_today += (day-1) * factor;
  for (i=1; i<month; i++)
  {
     base_today += days_in_month[year % 4][i-1] * factor;
  }

  for (i=1970; i<year; i++)
  {
     base_today += days_in_year[i % 4] * factor;
  }

  if(daylight == 1){base_today -= 3600;}
  base_today += tz_offset * 60;

    //.Subtract the two to get the counter value.//
       totalSec  = base_today - base_target;
      
   //.If near deadline totalSec is negative, decreasing in absolute value.//
   //.If at deadline then totalSec is zero.//
   //.If past deadline totalSec is positive, increasing in absolue value.//
  
   if (tz_offset != 0)
       totalSec += this_tz_offset * 60;

}

//.Display just the countdown timer.//
public void paintCountDownTimer(Graphics g)
{
    totalSec++; //.Increment the counter.//
    //.Show counter value.//
    System.out.println("totalSec= " + totalSec);

    //.Center display within applet border.//
    x_loc=5; y_loc=4;

    //.Show blank image.//
    theImage[13].paintIcon(this,g,x_loc,y_loc);

    //.Add blank spacer.//
    x_loc+=digit_space;
   
    //.Show "T Minus" image before deadline.//
    if(totalSec  < 0) theImage[11].paintIcon(this,g,x_loc,y_loc);

    //.Show "T Plus" image after deadline.//
    if(totalSec  > 0) theImage[12].paintIcon(this,g,x_loc,y_loc);

    //.Display status bar message on deadline.//
    if(totalSec == 0) showStatus(saying);

    //.Add a digit spacer.//
    x_loc+=digit_space;
       
        tSec = Math.abs(totalSec);
        rDays = (int) Math.floor (tSec / (24.0*60*60) );
        rHours = (int) Math.floor((tSec % (24*60*60)) / 3600.0);
        rMinutes = (int) Math.floor( (tSec % 3600) /60.0);
        rSecs = tSec % 60; 
   
        //.Show days digit.//
        theImage[rDays/1000].paintIcon(this,g,x_loc,y_loc);

        //.Add a digit spacer.//
        x_loc+=digit_space;

        //.Show days digit.//
        theImage[(rDays % 1000) / 100].paintIcon(this,g,x_loc,y_loc);

        //.Add digit spacer.//
        x_loc+=digit_space;

        //.Show days digit.//
        theImage[(rDays % 100) / 10].paintIcon(this,g,x_loc,y_loc);

        //.Add digit spacer.//
        x_loc+=digit_space;

        //.Show days digit.//
        theImage[rDays % 10].paintIcon(this,g,x_loc,y_loc);

        //.Add digit spacer.//
        x_loc+=digit_space;

        //.Show colon image.//
        theImage[10].paintIcon(this,g,x_loc,y_loc);

        //.Add colon spacer.//
        x_loc+=colon_space;

        //.Show hours digit.//
        theImage[rHours / 10].paintIcon(this,g,x_loc,y_loc);

        //.Add digit spacer.//
        x_loc+=digit_space;

        //.Show hours digit.//
        theImage[rHours % 10].paintIcon(this,g,x_loc,y_loc);

        //.Add digit spacer.//
        x_loc+=digit_space;

        //.Show colon image.//
        theImage[10].paintIcon(this,g,x_loc,y_loc);

        //.Add colon spacer.//
        x_loc+=colon_space;

        //.Show minutes digit.//
        theImage[rMinutes / 10].paintIcon(this,g,x_loc,y_loc);

        //.Add digit spacer.//
        x_loc+=digit_space;

        //.Show minutes digit.//
        theImage[rMinutes % 10].paintIcon(this,g,x_loc,y_loc);

        //.Add digit spacer.//
        x_loc+=digit_space;

        //.Show colon image.//
        theImage[10].paintIcon(this,g,x_loc,y_loc);

        //.Add colon spacer.//
        x_loc+=colon_space;

        //.Show seconds digit.//
        theImage[rSecs / 10].paintIcon(this,g,x_loc,y_loc);

        //.Add digit spacer.//
        x_loc+=digit_space;

        //.Show seconds digit.//
        theImage[rSecs % 10].paintIcon(this,g,x_loc,y_loc);

        //.Add digit spacer.//
        x_loc+=digit_space;
               
}

//.Display countdown clock digits and current date & time clock under it.// 
public void paintDigClk(Graphics g) {
 
    totalSec++; //.Increment the counter.//
    //.Show counter value.//
    System.out.println("totalSec= " + totalSec);

    //.Center display within applet border.//
    x_loc=5; y_loc=4;

    //.Show blank image.//
    theImage[13].paintIcon(this,g,x_loc,y_loc);

    //.Add blank spacer.//
    x_loc+=digit_space;
   
    //.Show "T Minus" image before deadline.//
    if(totalSec  < 0) theImage[11].paintIcon(this,g,x_loc,y_loc);

    //.Show "T Plus" image after deadline.//
    if(totalSec  > 0) theImage[12].paintIcon(this,g,x_loc,y_loc);

    //.Display status bar message on deadline.//
    if(totalSec == 0) showStatus(saying);

    //.Add a digit spacer.//
    x_loc+=digit_space;
       
        tSec = Math.abs(totalSec);
        rDays = (int) Math.floor (tSec / (24.0*60*60) );
        rHours = (int) Math.floor((tSec % (24*60*60)) / 3600.0);
        rMinutes = (int) Math.floor( (tSec % 3600) /60.0);
        rSecs = tSec % 60; 
   
        //.Show days digit.//
        theImage[rDays/1000].paintIcon(this,g,x_loc,y_loc);

        //.Add a digit spacer.//
        x_loc+=digit_space;

        //.Show days digit.//
        theImage[(rDays % 1000) / 100].paintIcon(this,g,x_loc,y_loc);

        //.Add digit spacer.//
        x_loc+=digit_space;

        //.Show days digit.//
        theImage[(rDays % 100) / 10].paintIcon(this,g,x_loc,y_loc);

        //.Add digit spacer.//
        x_loc+=digit_space;

        //.Show days digit.//
        theImage[rDays % 10].paintIcon(this,g,x_loc,y_loc);

        //.Add digit spacer.//
        x_loc+=digit_space;

        //.Show colon image.//
        theImage[10].paintIcon(this,g,x_loc,y_loc);

        //.Add colon spacer.//
        x_loc+=colon_space;

        //.Show hours digit.//
        theImage[rHours / 10].paintIcon(this,g,x_loc,y_loc);

        //.Add digit spacer.//
        x_loc+=digit_space;

        //.Show hours digit.//
        theImage[rHours % 10].paintIcon(this,g,x_loc,y_loc);

        //.Add digit spacer.//
        x_loc+=digit_space;

        //.Show colon image.//
        theImage[10].paintIcon(this,g,x_loc,y_loc);

        //.Add colon spacer.//
        x_loc+=colon_space;

        //.Show minutes digit.//
        theImage[rMinutes / 10].paintIcon(this,g,x_loc,y_loc);

        //.Add digit spacer.//
        x_loc+=digit_space;

        //.Show minutes digit.//
        theImage[rMinutes % 10].paintIcon(this,g,x_loc,y_loc);

        //.Add digit spacer.//
        x_loc+=digit_space;

        //.Show colon image.//
        theImage[10].paintIcon(this,g,x_loc,y_loc);

        //.Add colon spacer.//
        x_loc+=colon_space;

        //.Show seconds digit.//
        theImage[rSecs / 10].paintIcon(this,g,x_loc,y_loc);

        //.Add digit spacer.//
        x_loc+=digit_space;

        //.Show seconds digit.//
        theImage[rSecs % 10].paintIcon(this,g,x_loc,y_loc);

        //.Add digit spacer.//
        x_loc+=digit_space;
               
        //.Show blank image.//
        theImage[13].paintIcon(this,g,x_loc,y_loc);

        //.Add blank spacer.//
        x_loc+=digit_space;

        //.Show blank image.//
        theImage[13].paintIcon(this,g,x_loc,y_loc);

        //.Add blank spacer.//
        x_loc+=digit_space;


      //.-----------Current Date & Time display---------.//

     //.Get current date.//
     theDate = new Date();

    //.Center display within applet border.//
    x_loc=5; y_loc=28;
     
        rYear = theDate.getYear() - 100;
        rMonth = theDate.getMonth();
        rDay =  theDate.getDate();
        rHour = theDate.getHours();
        rMinute = theDate.getMinutes();
        rSecond = theDate.getSeconds(); 
                
        //.Show month digit.//
        theImage[rMonth/10].paintIcon(this,g,x_loc,y_loc);
        
        //.Add a digit spacer.//
        x_loc+=digit_space;

        //.Show month digit.//
        theImage[rMonth%10].paintIcon(this,g,x_loc,y_loc);

        //.Add a digit spacer.//
        x_loc+=digit_space;

        //.Show colon image.//
        theImage[10].paintIcon(this,g,x_loc,y_loc);

        //.Add colon spacer.//
        x_loc+=colon_space;

        //.Show colon image.//
        theImage[10].paintIcon(this,g,x_loc,y_loc);

        //.Add colon spacer.//
        x_loc+=colon_space;
         
        //.Show days digit.//
        theImage[rDay/10].paintIcon(this,g,x_loc,y_loc);

        //.Add a digit spacer.//
        x_loc+=digit_space;

        //.Show days digit.//
        theImage[rDay % 10].paintIcon(this,g,x_loc,y_loc);

        //.Add digit spacer.//
        x_loc+=digit_space;

        //.Show colon image.//
        theImage[10].paintIcon(this,g,x_loc,y_loc);

        //.Add colon spacer.//
        x_loc+=colon_space;

        //.Show colon image.//
        theImage[10].paintIcon(this,g,x_loc,y_loc);

        //.Add colon spacer.//
        x_loc+=colon_space;

        //.Show year digit.//
        theImage[rYear / 10].paintIcon(this,g,x_loc,y_loc);

        //.Add digit spacer.//
        x_loc+=digit_space;

        //.Show year digit.//
        theImage[rYear % 10].paintIcon(this,g,x_loc,y_loc);

        //.Add digit spacer.//
        x_loc+=digit_space;

        //.Add spacer to seperate date from time.//
        x_loc+=dead_space;

        //.Show hours digit.//
        theImage[rHour / 10].paintIcon(this,g,x_loc,y_loc);

        //.Add digit spacer.//
        x_loc+=digit_space;

        //.Show hours digit.//
        theImage[rHour % 10].paintIcon(this,g,x_loc,y_loc);

        //.Add digit spacer.//
        x_loc+=digit_space;

        //.Show colon image.//
        theImage[10].paintIcon(this,g,x_loc,y_loc);

        //.Add colon spacer.//
        x_loc+=colon_space;

        //.Show minutes digit.//
        theImage[rMinute / 10].paintIcon(this,g,x_loc,y_loc);

        //.Add digit spacer.//
        x_loc+=digit_space;

        //.Show minutes digit.//
        theImage[rMinute % 10].paintIcon(this,g,x_loc,y_loc);

        //.Add digit spacer.//
        x_loc+=digit_space;

        //.Show colon image.//
        theImage[10].paintIcon(this,g,x_loc,y_loc);

        //.Add colon spacer.//
        x_loc+=colon_space;

        //.Show seconds digit.//
        theImage[rSecond / 10].paintIcon(this,g,x_loc,y_loc);

        //.Add digit spacer.//
        x_loc+=digit_space;

        //.Show seconds digit.//
        theImage[rSecond % 10].paintIcon(this,g,x_loc,y_loc);
        theDate = null;

}

//.Display time & date clock digits.// 
public void paintlocClk(Graphics g)
{

    theDate = new Date();

    //.Center display within applet border.//
    x_loc=5; y_loc=4;
     
        rYear = theDate.getYear() - 100;
        rMonth = theDate.getMonth();
        rDay =  theDate.getDate();
        rHour = theDate.getHours();
        rMinute = theDate.getMinutes();
        rSecond = theDate.getSeconds(); 
    
       
          System.out.println(rMonth + " " + rDay + " " + rYear);

        //.Show month digit.//
        theImage[rMonth/10].paintIcon(this,g,x_loc,y_loc);
        
        //.Add a digit spacer.//
        x_loc+=digit_space;

        //.Show month digit.//
        theImage[rMonth%10].paintIcon(this,g,x_loc,y_loc);

        //.Add a digit spacer.//
        x_loc+=digit_space;

        //.Show colon image.//
        theImage[10].paintIcon(this,g,x_loc,y_loc);

        //.Add colon spacer.//
        x_loc+=colon_space;

        //.Show colon image.//
        theImage[10].paintIcon(this,g,x_loc,y_loc);

        //.Add colon spacer.//
        x_loc+=colon_space;

        //.Show days digit.//
        theImage[rDay/10].paintIcon(this,g,x_loc,y_loc);

        //.Add a digit spacer.//
        x_loc+=digit_space;

        //.Show days digit.//
        theImage[rDay % 10].paintIcon(this,g,x_loc,y_loc);

        //.Add digit spacer.//
        x_loc+=digit_space;

        //.Show colon image.//
        theImage[10].paintIcon(this,g,x_loc,y_loc);

        //.Add colon spacer.//
        x_loc+=colon_space;

        //.Show colon image.//
        theImage[10].paintIcon(this,g,x_loc,y_loc);

        //.Add colon spacer.//
        x_loc+=colon_space;

        //.Show year digit.//
        theImage[rYear / 10].paintIcon(this,g,x_loc,y_loc);

        //.Add digit spacer.//
        x_loc+=digit_space;

        //.Show year digit.//
        theImage[rYear % 10].paintIcon(this,g,x_loc,y_loc);

        //.Add digit spacer.//
        x_loc+=digit_space;

        //.Add digit spacer.//
        x_loc+=digit_space;
        
        //.Show hours digit.//
        theImage[rHour / 10].paintIcon(this,g,x_loc,y_loc);

        //.Add digit spacer.//
        x_loc+=digit_space;

        //.Show hours digit.//
        theImage[rHour % 10].paintIcon(this,g,x_loc,y_loc);

        //.Add digit spacer.//
        x_loc+=digit_space;

        //.Show colon image.//
        theImage[10].paintIcon(this,g,x_loc,y_loc);

        //.Add colon spacer.//
        x_loc+=colon_space;

        //.Show minutes digit.//
        theImage[rMinute / 10].paintIcon(this,g,x_loc,y_loc);

        //.Add digit spacer.//
        x_loc+=digit_space;

        //.Show minutes digit.//
        theImage[rMinute % 10].paintIcon(this,g,x_loc,y_loc);

        //.Add digit spacer.//
        x_loc+=digit_space;

        //.Show colon image.//
        theImage[10].paintIcon(this,g,x_loc,y_loc);

        //.Add colon spacer.//
        x_loc+=colon_space;

        //.Show seconds digit.//
        theImage[rSecond / 10].paintIcon(this,g,x_loc,y_loc);

        //.Add digit spacer.//
        x_loc+=digit_space;

        //.Show seconds digit.//
        theImage[rSecond % 10].paintIcon(this,g,x_loc,y_loc);
        theDate = null;
}


//.Start applet display.//
public void start()
{
      
      if(timer == null)
      {
         timer = new Thread(this);
         timer.start();
      }
}

//.Shut down thread if closing applet.//
public void stop()
{
    timer = null;
}

//.Run applet from current thread.//
public void run()
{

    Thread me = Thread.currentThread();
    while (timer == me)
    {
        try
        {
             Thread.currentThread().sleep(1000);
        }
        catch (InterruptedException e)
        {
           System.out.println("Interrupted Exception Error!");
        }
        repaint(); //.Update the graphics by calling update method.//
    }
}

public void update(Graphics g)
{
   paintCountDownTimer(g);
}

public boolean mouseEnter(Event evt, int x, int y)
{
    System.out.println("Developed by: Michael Hartman");
    System.out.println("hartmms@eng.auburn.edu");
    return(true);
}

public boolean mouseUp(Event evt, int x, int y)
{
        getAppletContext().showDocument(dest);
        return(true);
}


}



thats the code...
Was This Post Helpful? 0
  • +
  • -

#10 1lacca  Icon User is offline

  • code.rascal
  • member icon

Reputation: 44
  • View blog
  • Posts: 3,822
  • Joined: 11-August 05

Re: HTML to Java Applet

Posted 16 October 2005 - 11:18 AM

You have subcalssed Applet correctly, no problem there.

The applet is actually started, but for me it wrote the following in the java console:

Malformed URL: Check Applet tag.
totalSec= 1
Exception in thread "AWT-EventQueue-2" java.lang.NullPointerException
at countdown.paintCountDownTimer(countdown.java:207)
at countdown.update(countdown.java:729)
at sun.awt.RepaintArea.updateComponent(Unknown Source)
at sun.awt.RepaintArea.paint(Unknown Source)
at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)


You can access it by right clicking the little java symbol in the system tray.

And an advice: the java coding style suggests capitalizing the first letter of class names, so you avoid name resolution problems against package names.
Was This Post Helpful? 0
  • +
  • -

#11 Rk47  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 27
  • Joined: 11-October 05

Re: HTML to Java Applet

Posted 16 October 2005 - 11:25 AM

I couldn't run the applet. Embedding the applet in the HTML is working fine. Get Jgrasp , its an IDE that runs the applet without HTML.

http://www.eng.aubur...research/grasp/

I used the follwing and got the html working , well it doesn't say any applet loading failure.


<applet code="countdown.class" width="1000" height="800">

Change the file name into countdown and name the HTML file as countdown.html.
Was This Post Helpful? 0
  • +
  • -

#12 1lacca  Icon User is offline

  • code.rascal
  • member icon

Reputation: 44
  • View blog
  • Posts: 3,822
  • Joined: 11-August 05

Re: HTML to Java Applet

Posted 16 October 2005 - 12:36 PM

Unfortunately you can not test his applet if you embed it into an html like that, because it tries to load a couple of pictures from his server, and it cannot find it on your machine.

I have used:
<applet codebase="http://lowrie.50webs.com/" code="countdown.class" width="1000" height="800">

and it produced the errors I have copied in my previous post.
Was This Post Helpful? 0
  • +
  • -

#13 Lowrie  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 15
  • Joined: 14-July 05

Re: HTML to Java Applet

Posted 17 October 2005 - 02:35 PM

ok, i got one of the codes working, but now the code i really want on my website dosnt, what do i have to do to make the HTML read the java code?
i think i read somthing about subclass then somone edited...
Was This Post Helpful? 0
  • +
  • -

#14 1lacca  Icon User is offline

  • code.rascal
  • member icon

Reputation: 44
  • View blog
  • Posts: 3,822
  • Joined: 11-August 05

Re: HTML to Java Applet

Posted 17 October 2005 - 11:59 PM

Sorry for the question, but did you write this applet, or have you found it and want to use it on your website?
The latter is no problem, but looking at the Javacode and the embedding HTML code you've provided, the following occured to me:
- it needs some parameters set in the applet tag (although some of them have a default value) and those are not set in the example you've provided
- it wants to load some pictures, and if you don't have them at the right place, it's gonna throw errors - as it does right now

So if you've found it somewhere, read the documentation that accompanies it - as I am sure, that it has installation instructions.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1