MY MALL & NEWS
Coding Your Web Site



Adding Java Applets






There are two ways to add client-side Java to your site. The first is to download the Java 2 SDK, Standard Edition from java.sun.com and create your own applets. Alternatively, there are many sites with free or cheap source that is available for your site.
Below are simple examples of Java applet coding. After installing the JDK on your computer, you can create and compile code much like you see below through your DOS prompt using a javac command. The Java site has excellent tutorials, so I won't attempt to do more than merely introduce you to the idea of using Java on your site.
Good luck in building your site!




import java.awt.Graphics;

public class FirstApplet extends java.applet.Applet
{

   public void paint(Graphics g)
  {
   g.drawLine(0, 0, 200, 200);
  }
}




import java.applet.Applet;
import java.awt.Graphics;
import java.awt.Color;

public class Bullseye extends Applet {

  public void paint(Graphics g) {

   int RectLeft, RectTop, RectHeight, RectWidth;
   int AppletHeight = size().height;
   int AppletWidth = size().width;

     for (int i=8; i >= 0; i--) {
    if ((i % 2) == 0) g.setColor(Color.red);
    else g.setColor(Color.white);
    RectHeight = AppletHeight*i/8;
    RectWidth = AppletWidth*i/8;
    RectLeft = AppletWidth/2 - i*AppletWidth/16;
    RectTop = AppletHeight/2 - i*AppletHeight/16;
    g.fillOval(RectLeft, RectTop, RectWidth, RectHeight);
   }

  }

}




First Page | Previous Page

separator line

About | Site Map | Archives | Home

Sedo - Buy and Sell Domain Names and Websites project info: mymallandnews.com Statistics for project mymallandnews.com etracker® web controlling instead of log file analysis