java2实用教程〔第3版〕第7章课后习题解析〔耿祥义〕
import java.awt.*;
import java.awt.event.*;
import java.util.*;
public class T7_4 {
public static void main(String [] args) {
FirstWindow win = new FirstWindow("计算的窗口");
}
}
class FirstWindow extends Frame implements TextListener{
TextArea textA1,textA2;
FirstWindow(String s) {
setTitle(s);
setLayout(new FlowLayout());
textA1 = new TextArea(6,15);
textA2 = new TextArea(6,15);
add(textA1);
add(textA2);
textA1.addTextListener(this);
setBounds(0,0,300,300);
setVisible(true);
validate();
}
public void textValueChanged(TextEvent e) {
String s = textA1.getText();
StringTokenizer fenxi = new StringTokenizer(s," \n\r");
int n