• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

missing colour

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, both for your answer (the book is from 1997 so yes, it is out of date) & for your welcome to JavaRanch!

Best, Jeff
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic