• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

applet help please

 
kieran pattni
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i cant seem to load my applet..please can someone tell me what i am doing wrong..code compiles fine...

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

public class HelloWorldApplet extends Applet
{
private int paintCounter;

public void init()
{
paintCounter = 0;
}

public void paint(Graphics g)
{
g.setColor(Color.yellow);
g.fillRect(15, 5, 216,186);
g.setColor(Color.black);
g.drawString("Hello World",25,25);
paintCounter++;
g.drawString("Number of times paint() called: "+
paintCounter, 25,50);
}
}



html code...

<HTML>
<HEAD>
<TITLE>The first applet </TITLE>
</HEAD>
<BODY>
Heres comes my first applet:
<BR>
<APPLET CODE="HelloWorldApplet.class"WIDTH=200 HEIGHT=50>
</APPLET>
</BODY>
</HTML>

html file saved as test4.txt ...all files including xxx.class file in same dir. i load Ineternet Explorer..goto file..open..load test4.txt...all i get is html code above..help..
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Save the file as test4.html
 
kieran pattni
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi..i tried test4.html...but till no result...just get html code that i have typed...
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have a JVM installed? If you do, there should be a Java Console displaying messages - are there any?
 
Kia Phia Ben
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I compile with jdk 1.5 and run html with firefox 1.5. Run OK.
I think you see again JRE
 
kieran pattni
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello again....my jvm is installed..i do have java console...i have tested jvm it works ok...i have 1.3.1 version...when i go other websites to see demo applets they work fine..
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are a few things you can investigate:
  • Are there any messages in the Java Console?
  • Are there any messages in the browser status bar?
  • Can you run the applet with appletviewer?
  • Is the correct JVM selected in the Java Plugin control panel?
  •  
    kieran pattni
    Ranch Hand
    Posts: 47
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    The java console doesnt display any messages when try run code for the applet..
     
    Eoin Mac Aoidh
    Ranch Hand
    Posts: 48
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Kieran,
    I refer to the second or third post above;
    hi..i tried test4.html...but till no result...just get html code that i have typed...

    Are you using windows?
    -In your folder settings you need to make visible the extensions for known

    file types >tools>folder options>view> then make sure the box for "hide extensions for known file types" is unchecked

    I think the problem is that you are renaming the file "test4.html" but because the extension is hidden it is renamed as test4.html.txt but you cant see the txt extension. So when you show known file types, just delete the txt extension and you should have a regular html file which will display your applet.
    Best of luck,

    E.
     
    kieran pattni
    Ranch Hand
    Posts: 47
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    thank guys for your help ...Eoin Mac Aoidh ..u were right...thanks a million
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic