Highlights
All Snippets
Top 100 Snippets
Librarians
gbCodeLib

By Language
VB6
JavaScript
Perl
HTML
SQL
Java
DOS

GBIC >> Source Code >> Java >> Snippet

02 Simple Java Applet


import java.awt.Graphics;
public class MyApplet extends Applet {
   public void paint (Graphics g) {
     g.drawString( "Have a nice day." , 50,25);
   }
}

In this example, the import refers to the Java Abstract Windowing Toolkit (AWT), which
contains methods needed for putting graphics, text, lines, and dots on the browser screen
To compile this applet, save the above text as MyApplet.java then type :