帮忙做做这个了急用啊要对的啊
来源:百度知道 编辑:UC知道 时间:2024/09/24 07:09:28
//以":" 做为若干数的分隔,如在第一个文本区输入 123:123 这样会计算和为:246 平均值为: 123
import java.awt.*;
import java.awt.event.*;
import java.util.StringTokenizer;
class TextChange extends Frame implements TextListener, ActionListener {
TextArea text1, text2;
Button button;
TextChange(String s) {
super(s);
setLayout(new FlowLayout(FlowLayout.LEFT));
text1 = new TextArea();
text1.addTextListener(this);
text2 = new TextArea();
text2.setEditable(false);
button = new Button("清空");
button.addActionListener(this);
add(text1);
add(text2);
add(button);
setBounds(500, 200, 500, 400);
setVisible(true);
validate();
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
public void textValueChanged(TextEvent e) {
String a[] = new String[