Jump to content
  • Advertisement
Sign in to follow this  
meeksha

First Java Applet

This topic is 2595 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have uploaded everything to http://www.chooseyourecig.com/javagame/helloworld.html . When I visit this page from my computer (Windows Vista) using both Firefox and Internet Explorer, it works just fine. But when my brother visits on his computer (Windows 7) using the same browsers, it does not work. Also, when my daughter visits from her computer (Windows XP) using both Google Chrome and Internet Explorer, it does not work for her either. What is the most likely cause of this? Thanks in advance for any help you can provide.

Here is the java code

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

public class HelloWorld extends Applet
{
private Font a_Font;
Image coolImage;

public void init()
{
a_Font = new Font("Helvetica", Font.BOLD, 48);
setFont(a_Font);
coolImage = getImage(getCodeBase(), "hottie.jpg");
}

public void paint (Graphics g)
{
Color adamBlue = new Color (80,124,224);
g.setColor(adamBlue);
g.drawImage(coolImage,0,0,this);
g.drawString("Hello World!", 50, 75);
}
}

Here is the html

<HTML>
<HEAD>
<TITLE>Hello World Applet</TITLE>
</HEAD>
<BODY>
<CENTER>
<H1>Hello World Applet</H1>
<APPLET CODE="HelloWorld.class" WIDTH=500 HEIGHT=500>
</APPLET>
</BODY>
</HTML>

Share this post


Link to post
Share on other sites
Advertisement
You need to install the Java plugin for the browser for Java applets to run. Note that this is not the same as JavaScript.

Java Runtime can be downloaded from the Oracle website. http://www.oracle.com/technetwork/java/index-jsp-141438.html

Share this post


Link to post
Share on other sites
Modern browsers have developer consoles and tools hidden in one of their menus. You can use these to get error messages, which will help pinpoint what is going wrong.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!