Thursday, 20 June 2013

applet example

1-A simple example for how to use applets
this programme takes user input
name
date of birth
address
METHODS IN THE PROGRAMME
{
1-String a = JOptionPane.showInputDialog("enter your name");
IT IS USED TO DISPLAY AN INPUT DIALOGUE BOX ON SCREEN
2-g.drawString("name is", 25, 30);
IT IS A FUNCTION USED TO DISPLAY ON THE SCREEN 25,30 DECIDE THE
POSITION OF RESULT ON PAGE
}
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
import java.awt.*;

public class apl  extends Applet{
String a,b,c;
public void init(){
 a = JOptionPane.showInputDialog("enter your name");
 b=JOptionPane.showInputDialog("enter your dob");
 c=JOptionPane.showInputDialog("enter your address");

}
public void paint(Graphics g)
{

g.drawString("name is"+a, 25, 30);
g.drawString("dob is"+b, 45, 30);
g.drawString("address is"+c, 65, 30);
}
}
]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]

2----save this file as" .html" file anr run it it will automatically inherit the class
now only java can not run a applet so you need to know a bit of html
<HTML>
<body>
<applet code="usr.class",width="500",height="500">
</applet>
</body>
</HTML>



No comments:

Post a Comment