Java Logo Design Example

In this program, it shows you on how to create a simple logo using java applet. Java applet is a small application which is written in Java and delivered to users in the form of bytecode. The user launches the Java applet from a web page, and the applet is then executed within a Java Virtual Machine (JVM) in a process separate from the web browser itself. A Java applet can appear in a frame of the web page, a new application window, Sun's AppletViewer, or a stand-alone tool for testing applets.

The following example illustrates the use of Java applets through the java.applet package. The example also uses classes from the Java Abstract Window Toolkit (AWT) to produce the graphical output.

How it works?

1. First type in the source code and save it into file named

import java.awt.*;
public class Levis extends java.applet.Applet {
Font font=new Font("Arial Black",Font.BOLD,80);
Font font1=new Font("Arial Black",Font.BOLD,25);
Font font2=new Font("Goudy Old Style",Font.BOLD,35);
Font font3=new Font("Times New Roman",Font.BOLD,13);
    int x[]={50,450,450,410,410,90,90,50};
    int y[]={130,130,130,320,320,320,320,130};
    public void paint(Graphics g){
        g.fillOval(399,155,19,19) ;
        g.fillOval(401,157,15,15) ;
        g.drawString("LEVI STRAUSS & CO.",100,270);
        g.fillOval(90,312,15,15) ;
        g.fillOval(396,310,15,15) ;
        g.drawString("O R I G I N A L",130,120);
        g.drawString("R I V E T E D",146,360);

2. Compile this file in the usual way. If all is well a file called Levis.class will be created. Now you need to create an HTML file that will include your applet. The following simple HTML file will do.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

     <body bgcolor="000000">
code = "Levis.class"
width "500"
height "300">

3. Save this file as Logo.html in the same directory as the Levis.class file. Then run the Logo.html using any Internet Browser or JCreator IDE.


Programming Language: Java
Programming IDE: JCreator

1 (mga) komento: