Hello World Example
/*
By Bavo Bruylandt (Http://www.realapplets.com")
*/
// and now The inevitable "Hello World" example
:)
// tell the compiler where to find the methods
you will use.
// required when you create an applet
import java.applet.*;
// required to paint on screen
import java.awt.*;
// the start of an applet - HelloWorld will be
the executable class
// Extends applet means that you will build the
code on the standard Applet class
public class HelloWorld extends Applet
{
// The method that will be automatically called
when the applet is started
public void init()
{
// It is required but does not need anything.
}
// This method gets called when the applet is
terminated
// That's when the user goes to another page
or exits the browser.
public void stop()
{
// no actions needed
here now.
}
// The standard method that you have to use to
paint things on screen
// This overrides the empty Applet method, you
can't called it "display" for example.
public void paint(Graphics g)
{
//method to draw text on screen
// String first, then x and y coordinate.
g.drawString("Hey hey hey",20,20);
g.drawString("Hellooow World",20,40);
}
}
// That's it. Next is drawing special shapes on
screen and using fonts.
// Go to DrawExample.java.
Next...
New on the Java Boutique:
New Review:
Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling
API boasts simplicity, ease-of-integration, a well-rounded feature
set, and it's free!
New Applet:
Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA
sequences into three useful formats.
Elsewhere on internet.com:
WebDeveloper Java
Lots of Java information on webdeveloper.com
WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.
ScriptSearch Java
Hundreds of free Java code files to download.
jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.
|