//Java Code
//Save as: myApplet.java
import java.awt.*;
import java.applet.*;
public class myApplet extends Applet{
TextField t1,t2;
public void init(){
t1=new TextField(10);
t2=new TextField(10);
add(t1);
add(t2);
t1.setText("0");
t2.setText("0");
}
public void paint(Graphics g){
int x=0,y=0,sum=0;
String s,s1,s2;
g.drawString("Enter the value in the Blank Field.",1,50);
try{
s1=t1.getText();
x=Integer.parseInt(s1);
s2=t2.getText();
y=Integer.parseInt(s2);
}catch(Exception e){}
sum=x+y;
s=String.valueOf(sum);
g.drawString("sum",3,70);
g.drawString(s,50,70);
}
}
-----------------------------------------------------------------------------------------------------------------------
//HTML Code
//Save as:myApplet.html
<html>
<head>
<title>applet program</title>
<head/>
<body>
<applet code=myApplet.class width=200 height=300>
</applet>
</body>
</html>
//Save as: myApplet.java
import java.awt.*;
import java.applet.*;
public class myApplet extends Applet{
TextField t1,t2;
public void init(){
t1=new TextField(10);
t2=new TextField(10);
add(t1);
add(t2);
t1.setText("0");
t2.setText("0");
}
public void paint(Graphics g){
int x=0,y=0,sum=0;
String s,s1,s2;
g.drawString("Enter the value in the Blank Field.",1,50);
try{
s1=t1.getText();
x=Integer.parseInt(s1);
s2=t2.getText();
y=Integer.parseInt(s2);
}catch(Exception e){}
sum=x+y;
s=String.valueOf(sum);
g.drawString("sum",3,70);
g.drawString(s,50,70);
}
}
-----------------------------------------------------------------------------------------------------------------------
//HTML Code
//Save as:myApplet.html
<html>
<head>
<title>applet program</title>
<head/>
<body>
<applet code=myApplet.class width=200 height=300>
</applet>
</body>
</html>
Comments
Post a Comment