wood burning stoves 2.0*
The moose likes Applets and the fly likes missing colour Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "missing colour" Watch "missing colour" New topic
Author

missing colour

Jeff Kess
Greenhorn

Joined: Feb 27, 2010
Posts: 3
Hi, this is my 1st post here - I'm very new to programming, so this is probably really simple for most of you but hey, we're all beginners at 1st!

* jdk1.6.0_07 - i think
* jre-windows-i586
* crimson editor for the source files
* win xp home sp3
* anything else?

The beginners book I've started learning from gives the following code as the 1st applet. It compiles ok & runs in the browser, but "Hello from an applet!" appears on a white background, same as the rest of the window, instead of on a grey background as the book says it will.

This is exactly as its given in the book:

import java.applet.Applet;
import java.awt.Graphics;

public class HelloApp extends Applet
{
public void paint(Graphics g)
{
g.drawString("Hello from an applet!", 50, 20);
}
}

& this is the html code given to run it in a browser:

<html>
<head>
<title> The first applet </title>
</head>
<body>
Here comes my first applet:
<br>
<applet code= "HelloApp.class" width=200 height=50>
</applet>
</body>
</html>

Can anyone see what the problem might be? I've done it exactly as given in the book - I suppose the book could be wrong, but it seems more likely that i'm missing something. It's not that important, but it's niggling (bugging) me .

Anyway, this is also a way of "introducing myself" on the forum. Hi all!

Thanks, Jeff


Never test the depth of the water with both feet!
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41096
    
  44
Welcome to JavaRanch.

It appears on a white background for me as well. Generally, white is the default background color, and black the default foreground color. Maybe the book is somewhat dated and this has since changed, or maybe it's not defined at all what the default color is, and the author's JVM just happens to use grey. Either way, I'm certain that you're not doing anything wrong :-)


Ping & DNS - my free Android networking tools app
Jeff Kess
Greenhorn

Joined: Feb 27, 2010
Posts: 3
Thanks, both for your answer (the book is from 1997 so yes, it is out of date) & for your welcome to JavaRanch!

Best, Jeff
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Jeff Kess wrote:the book is from 1997 so yes, it is out of date

Welcome to Java... but that book is not just out of date, it's WAY out of date. It's probably one of those first-generation books which jumped into applets in about Chapter 2, am I right? I would seriously recommend tossing it out and starting with a newer book.
Jeff Kess
Greenhorn

Joined: Feb 27, 2010
Posts: 3
I’m beginning to see that, but it’s a library book, so at least it didn’t cost me! I’m trying to get a later edition as he explains the basic concepts well.

J
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: missing colour
 
Similar Threads
viewing applet in IE
applet not working
using applets in html
HelloWorld not working
not working on ie