Syntax for Execute this program :
Firstly then name of class and file should be and run your java file
Syntax : Appletviewer filename.java
Example : Appletviewer simple_applet.javaimport java.awt.*;
import java.applet.*;
import java.util.*;
/*
<html>
<head>
</head>
<body>
Welcome to my New Java Code
<br/>
<applet code="font_colors" width=800 height=800>
</applet>
</body>
</html>
*/
public class font_colors extends Applet implements Runnable
{
public void init()
{
Thread t = new Thread(this);
t.start();
}
public void run()
{
try
{
repaint();
}
catch(Exception e)
{
}
}
public void paint(Graphics g)
{
Font f = new Font("Arial",1,24);
g.setFont(f);
Color c = new Color(0,0,255);
g.setColor(c);
Color c1 = g.getColor();
g.drawString(""+c1.getBlue(),100,200);
g.drawString("This is my first Program in applet ",100,40);
}
}
OUTPUT
This is my first program in applet