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
* 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.
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!
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 :-)
posted 9 years ago
Thanks, both for your answer (the book is from 1997 so yes, it is out of date) & for your welcome to JavaRanch!
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.
posted 9 years ago
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.
Never test the depth of the water with both feet!
If you were a tree, what sort of tree would you be? This tiny ad is a poop beast.
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps