Click to See Complete Forum and Search --> : Steps to execute Applets


Miss Strawberry
11-10-2006, 10:46 PM
Can anyone tell me how can I excute applets using the web??

Miss Strawberry
11-10-2006, 11:07 PM
Can anyone tell me what's wrong with my code.. It doesnt work??:(
<html>
<head>
</head>
<body bgcolor="000000">
<center>
<applet
code = "Einstein.class"
width = "500"
height = "300"
>


import javax.swing.JApplet;
import java.awt.*;
public class Text1 extends JApplet
{

public void Paint (Graphics Page)
{
final int MID =150;
final int TOP =50;

setBackground (Color.cyan);

Page.setColor (Color.blue);
Page.fillRect (0, 175, 300, 50);

Page.setColor(Color.yellow);
Page.fillOval(-40, -40, 80, 80);

Page.setColor(Color.white);
Page.fillOval(MID-20, TOP, 40, 40);
Page.fillOval(MID-35, TOP+35, 70, 50);
Page.fillOval(MID-50, TOP+80, 100, 60);

Page.setColor(Color.black);
Page.fillOval(MID-10, TOP+10, 5, 5);
Page.fillOval(MID+5, TOP+10, 5, 5);

Page.drawArc(MID-10, TOP+20, 20, 10, 190, 160);
Page.drawLine(MID-25, TOP+60, MID-50, TOP+40);

Page.drawLine(MID-20, TOP+5, MID+20, TOP+5);
Page.fillRect(MID-15, TOP-20, 30, 25);

}
}



</applet>
</center>
</body>
</html>

TheBearMay
11-10-2006, 11:13 PM
This code goes in your web page (note that applet has been depreciated in favor of object):

<html>
<head>
</head>
<body bgcolor="000000">
<center>
<applet code = "Einstein.class" width = "500" height = "300" >
</applet>
</center>
</body>
</html>

This code goes into a file called Einstein.java and is "compiled" using the JAVA compiler to create Einstein.class

import javax.swing.JApplet;
import java.awt.*;
public class Text1 extends JApplet
{

public void Paint (Graphics Page)
{
final int MID =150;
final int TOP =50;

setBackground (Color.cyan);

Page.setColor (Color.blue);
Page.fillRect (0, 175, 300, 50);

Page.setColor(Color.yellow);
Page.fillOval(-40, -40, 80, 80);

Page.setColor(Color.white);
Page.fillOval(MID-20, TOP, 40, 40);
Page.fillOval(MID-35, TOP+35, 70, 50);
Page.fillOval(MID-50, TOP+80, 100, 60);

Page.setColor(Color.black);
Page.fillOval(MID-10, TOP+10, 5, 5);
Page.fillOval(MID+5, TOP+10, 5, 5);

Page.drawArc(MID-10, TOP+20, 20, 10, 190, 160);
Page.drawLine(MID-25, TOP+60, MID-50, TOP+40);

Page.drawLine(MID-20, TOP+5, MID+20, TOP+5);
Page.fillRect(MID-15, TOP-20, 30, 25);

}
}