Java Applet
Java Applet
Applet is initialized.
Applet is started.
Applet is painted.
Applet is stopped.
Applet is destroyed.
java.applet.Applet class
//First.java
import java.applet.Applet;
import java.awt.Graphics;
public class First extends Applet{
//First.java
import java.applet.Applet;
import java.awt.Graphics;
public class First extends Applet{
g.setColor(Color.pink);
g.fillOval(170,200,30,30);
g.drawArc(90,150,30,30,30,270);
g.fillArc(270,150,30,30,0,180);
}}
myapplet.html
<html>
<body>
<applet code="GraphicsDemo.class" width="300"
height="300">
</applet>
</body>
</html>
Displaying Image in Applet
Image picture;
}
myapplet.html
<html>
<body>
<applet code="DisplayImage.class" width="300"
height="300">
</applet>
</body>
</html>
Animation in Applet
import java.awt.*;
import java.applet.*;
public class AnimationExample extends Applet {
Image picture;
try{Thread.sleep(100);}catch(Exception e){}
}
}
}
myapplet.html
<html>
<body>
<applet code="DisplayImage.class" width="300"
height="300">
</applet>
</body>
</html>
EventHandling in Applet
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class EventApplet extends Applet implements ActionListener{
Button b;
TextField tf;
b=new Button("Click");
b.setBounds(80,150,60,50);
add(b);add(tf);
b.addActionListener(this);
setLayout(null);
}
public void actionPerformed(ActionEvent e){
tf.setText("Welcome");
}
}
myapplet.html
<html>
<body>
<applet code="EventApplet.class" width="300"
height="300">
</applet>
</body>
</html>