This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Applets and the fly likes applet help please Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "applet help please" Watch "applet help please" New topic
Author

applet help please

kieran pattni
Ranch Hand

Joined: Jan 19, 2004
Posts: 47
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

Joined: Feb 07, 2005
Posts: 2367
Save the file as test4.html
kieran pattni
Ranch Hand

Joined: Jan 19, 2004
Posts: 47
hi..i tried test4.html...but till no result...just get html code that i have typed...
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41182
    
  45
Do you have a JVM installed? If you do, there should be a Java Console displaying messages - are there any?


Ping & DNS - my free Android networking tools app
Kia Phia Ben
Ranch Hand

Joined: Dec 16, 2005
Posts: 48
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

Joined: Jan 19, 2004
Posts: 47
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
Marshal

Joined: Mar 22, 2005
Posts: 41182
    
  45
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

    Joined: Jan 19, 2004
    Posts: 47
    The java console doesnt display any messages when try run code for the applet..
    Eoin Mac Aoidh
    Ranch Hand

    Joined: May 19, 2005
    Posts: 48
    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

    Joined: Jan 19, 2004
    Posts: 47
    thank guys for your help ...Eoin Mac Aoidh ..u were right...thanks a million
     
    Don't get me started about those stupid light bulbs.
     
    subject: applet help please
     
    Similar Threads
    passing parameter to applet
    using applets in html
    Applet fetching problem in servlet
    applet and the html file in separate directory
    Can't run my applet on a html page