importjava.awt.*;importjava.awt.event.*;importjava.util.*;publicclassT7_4{publicstaticvoidmain(String[]args){FirstWindowwin=newFirstWindow(计算的窗口);}}classFirstWindowextendsFrameimplementsTextListener{TextAreatextA1,textA2;FirstWindow(Strings){setTitle(s);setLayout(newFlowLayout());textA1=newTextArea(6,15);textA2=newTextArea(6,15);add(textA1);add(textA2);textA1.addTextListener(this);setBounds(0,0,300,300);setVisible(true);validate();}publicvoidtextValueChanged(TextEvente){Strings=textA1.getText();StringTokenizerfenxi=newStringTokenizer(s,\n\r);intn=fenxi.countTokens();longsum=0;try{for(inti=0;in;i++){sum+=Long.parseLong(fenxi.nextToken());}textA2.setText(总和+String.valueOf(sum));doubleavg=(double)sum/n;textA2.append(\n平均数+String.valueOf(avg));}catch(NumberFormatExceptione1){//System.out.println(输入有误!);System.out.println(s);}}}importjava.awt.*;importjava.awt.event.*;publicclassT7_5{publicstaticvoidmain(String[]args){newMyFrame(挑单词);}}classMyFrameextendsFrameimplementsActionListener{TextAreata1,ta2;Buttonbtn;MyFrame(Strings){super(s);setLayout(newBorderLayout());ta1=newTextArea(5,15);ta2=newTextArea(5,15);btn=newButton(追加);btn.addActionListener(this);add(ta1,BorderLayout.EAST);add(ta2,BorderLayout.WEST);add(btn,BorderLayout.SOUTH);setBounds(100,100,300,200);setVisible(true);}publicvoidactionPerformed(ActionEvente){Strings=ta1.getSelectedText();ta2.append(s);}}//带关闭功能的窗口importjava.awt.*;importjava.awt.event.*;publicclassT7_6{publicstaticvoidmain(String[]args){newMathWindow(计算);}}classMathWindowextendsFrameimplementsActionListener{//定义一个类继承于Frame并实现了接口ActionListenerButtonbtn_Add,btn_Sub,btn_Mul,btn_Mov;//定义四个表示运算的按钮TextFieldtf1,tf2,tf3;//定义三个文本框Labell1,l2;//定义两个标签MathWindow(Strings){super(s);//设置标题setLayout(newFlowLayout());//设置窗口模式btn_Add=newButton(加);btn_Sub=newButton(减);btn_Mul=newButton(乘);btn_Mov=newButton(除);//实例化四个表示运算的按钮tf1=newTextField(8);tf2=newTextField(8);tf3=newTextField(8);//实例化三个文本框l1=newLabel(,1);l2=newLabel(=,1);//实例化两个标签add(tf1);add(l1);add(tf2);add(l2);add(tf3);add(btn_Add);add(btn_Sub);add(btn_Mul);add(btn_Mov);//将所需的组件加入到窗口中btn_Add.addActionListener(this);btn_Sub.addActionListener(this);btn_Mul.addActionListener(this);btn_Mov.addActionListener(this);//设置四个表示运算按钮的监视器为本窗口this.addWindowListener(newWindowAdapter(){publicvoidwindowClosing(WindowEvente){dispose();//撤销当前窗口}});setBounds(100,100,500,80);//设置窗口大小setResizable(false);//设置窗口大小是否可由用户改变setVisible(true);//设置窗口的显示状态validate();//刷新}publicvoidactionPerformed(ActionEvente){//实现ActionListener接口的方法Strings1=tf1.getText();Strings2=tf2.getText();//获取两个文本框的内容try{longm=Long.parseLong(s1);longn=Long.parseLong(s2);//将获取的文本框的内容转换成长整型if(e.getSource()==btn_Add){//判断事件的发生源并做出相应的处理l1.setText(+);tf3.setText(String.valueOf(m+n));}elseif(e.getSource()==btn_Sub){l1.setText(-);tf3.setText(String.valueOf(m-n));}elseif(e.getSource()==btn_Mul){l1.setText(x);tf3.setText(String.valueOf(m*n));}elseif(e.getSource()==btn_Mov){l1.setText(/);tf3.setText(String.valueOf(1.0*m/n));}else{System.exit(0);}}catch(NumberFormatExceptione1){//异常处理System.out.println(输入数字字符串!);}}}importjava.awt.*;importjava.awt.event.*;importjavax.swing.*;importjavax.swing.border.*;publicclassT7_7{publicstaticvoidmain(String[]args){WindowBoxwb=newWindowBox(确定);}}classWindowBoxextendsFrameimplementsActionListener{BoxbaseBox,boxV1,boxV2;TextFieldtf1,tf2,tf3;Buttonbtn_OK;TextAreata;WindowBox(Strings){super(s);tf1=newTextField(12);tf2=newTextField(12);tf3=newTextField(12);boxV1=Box.createVerticalBox();boxV1.add(newLabel(姓名));boxV1.add(Box.createVerticalStrut(8));boxV1.add(newLabel(E_mail));boxV1.add(Box.createVerticalStrut(8));boxV1.add(newLabel(职业));boxV2=Box.createVerticalBox();boxV2.add(tf1);boxV2.add(Box.createVerticalStrut(8));boxV2.add(tf2);boxV2.add(Box.createVerticalStrut(8));boxV2.add(tf3);baseBox=Box.createHorizontalBox();baseBox.add(boxV1);baseBox.add(Box.createHorizontalStrut(10));baseBox.add(boxV2);setLayout(newFlowLayout());btn_OK=newButton(提交);btn_OK.addActionListener(this);ta=newTextArea(5,20);add(baseBox);add(btn_OK);add(ta);setBounds(120,125,200,260);setResizable(false);setVisible(true);}publicvoidactionPerformed(ActionEvente){Stringregex=\\w{1,}@\\w{1,}\56\\w{1,};Stringname=tf1.getText();Stringemail=tf2.getText();Stringpos=tf3.getText();if(!email.matches(regex)){tf2.setText(非法E_mail地址);}else{Stringtotal=姓名:+name+\nE_mail:+email+\n职业:+pos;ta.append(total);}}}importjava.awt.*;importjava.awt.event.*;publicclassT7_8{publicstaticvoidmain(String[]args){newMyFrame(Panel);}}classMyPanelextendsPanelimplementsActionListener{TextFieldtf;Buttonbtn;MyPanel(){setLayout(newGridLayout(2,1));tf=newTextField(10);btn=newButton();add(tf);add(btn);btn.addActionListener(this);setVisible(true);}publicvoidactionPerformed(ActionEvente){Stringlabel=tf.getText();btn.setLabel(label);}}classMyFrameextendsFrame{MyPanelmp1,mp2;MyFrame(Strings){setLayout(newBorderLayout());mp1=newMyPanel();mp2=newMyPanel();add(mp1,BorderLayout.EAST);add(mp2,BorderLayout.WEST);pack();setVisible(true);}}importjava.awt.*;importjava.awt.ev