|
import javax.swing.JOptionPane;
import java.applet.*;
import java.awt.*;
public class dialog extends Applet {
TextField first,second,third;
int x,y,sum;
public void init() {
first =new TextField("first");
second =new TextField("second");
third =new TextField("third");
add(first);
add(second);
add(third);
}
public void start() {
x=Integer.parseInt(JOptionPane.showInputDialog(first));
y=Integer.parseInt(JOptionPane.showInputDialog(second));
sum=x+y;
first.setText(""+x);
second.setText(""+y);
third.setText(""+sum);
}
}
上面那条程序运行的时候看不到TextField的first and second,但是我注释了start()就可以显示三个TextField,为什么?? |
|