import java.awt.*;
import java.applet.*;
public class Appletdemo extends Applet
{
TextField text1,text2;
public void init()
{
text1=new TextField(10);
text2=new TextField(10);
add(text1);
add(text2);
text1.setText("");
text2.setText("");
}
public void paint(Graphics g)
{
int z=0,x=0,y=0;
String s1,s2,s;
g.drawString("input no in each textbox",10,50);
try
{
s1=text1.getText();
x=Integer.parseInt(s1);
s2=text2.getText();
y=Integer.parseInt(s2);
}
catch(Exception e)
{
}
z=x+y;
s=String.valueOf(z);
g.drawString("The sum is",10,80);
g.drawString(s,100,80);
}
public boolean action(Event event,Object object)
{
repaint();
return true;
}
}
这是我试图了解的代码
public boolean action(Event event,Object object)
{
repaint();
return true;
}
为什么我们在我们的程序中使用它。