File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

missing colour

Jeff Kess

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:

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

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

Joined: Mar 22, 2005
Posts: 42959
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 :-)
Jeff Kess

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

Joined: Oct 14, 2005
Posts: 19874

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

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.

I agree. Here's the link:
subject: missing colour
It's not a secret anymore!