题目内容
小应用程序设置一个文本区、一个文本框和两个按钮。用户在文本区中输入整数序列,单击求和按钮,程序对文本区中的整数序列进行求和,并在文本框中输出计算结果。单击第二个按钮,清除文本区和文本框中内容。注:这里是给定程序的部分代码,你要编写的是actionPerformed(ActionEvent e)方法。 import java.util. *;. . . . . . . . . public class Test38 extends Applet implements ActionListener { JTextArea textA; JTextField textF; JButton b1,b2; public void init() { textA=new JTextArea("",5,10); textF=new JTextField("",10); b1=new JButton("求和");b2=new JButton("重新开始"); b1. addActionListener(this);b2. addActionListener(this); add(textA);add(textF);add(b1);add(b2); ……..}public void actionPerformed(ActionEvent e){ //请在以下位置编写代码(例题Example5_9)}
查看答案
搜索结果不匹配?点我反馈
更多问题