Advanced Java Tutorial


Total available pages count: 55
Subject - Java Technologies

Create applet

An applet can be develop using JApplet Class or by extending either Applet class.

MyApplet.java

/*
<applet code="MyApplet" height=300" width="500"></applet>
*/
	import java.awt.*;
	import java.applet.*;
	public class MyApllet extends Applet
	{
	  public void paint(Graphics g)
	{
	  g.drawString("Hello world!",20, 20);
	}
}

 

In the above example, we can see class MyApplet extends Apple & it has method paint() that accepts the parameter of Graphics. here we can see Graphics class is part of the java.awt package so it’s used to display graphics or text on the applet.

Execute & Running Applet

  • Using web browser
  • Using appletViewer tool (testing purpose)


Comments