1.编写窗体应用程序,统计一个文本域输入文本的行数、单词数和字符数。可在图形界面中安排一个按钮、一个文本域和一个标签,点击按钮开始统计,在标签中显示结果。packagea.b.c;importjava.awt.*;importjava.awt.event.*;importjava.applet.*;publicclassex11_1extendsFrameimplementsActionListener{TextAreatextInput;Labelres;publicex11_1(){textInput=newTextArea(5,10);Panelp=newPanel();p.setLayout(newGridLayout(3,1,2,2));ButtoncountButton=newButton(ProcesstheText);countButton.addActionListener(this);p.add(countButton);res=newLabel(result......);p.add(res);setLayout(newBorderLayout(2,2));add(textInput,BorderLayout.CENTER);add(p,BorderLayout.SOUTH);setSize(300,300);setVisible(true);}publicvoidactionPerformed(ActionEventevt){Stringtext;intcharCt,wordCt,lineCt;text=textInput.getText();charCt=text.length();eordCt=0;for(inti=0;icharCt;i++){booleanstartOfWord;if(ICharacter.isLetter(text.charAt(i)))startOfWord=false;elseif(i==0)startOfWord=true;elseif(Character.isLetter(Text.charAt(i-1)))startOfWord=false;elsestartOfWord=true;if(startOfWord)wordCt++;}lineCt=1;for(inti=0;icharCt;i++){if(text.charAt(i)=='\n')lineCt++;}res.setText(Lines:+lineCt+,Words:+wordCt+,Chars:+charCt);}publicstaticvoidmain(Stringargs[]{newex11_1();}2.编写窗体应用程序,安排一个文本框、一个按钮和一个标签,从文本框录入一个数字(0~9),点击按钮将其对应的英文单词(如:zero,one等)显示在标签中。packagea.b.c;importjava.awt.*;importjava.awt.event.*;publicclassex11_2extendsFrameimplementsActionListener{Labelres;TextFieldmy;Stringword[]={zero,one,two,three,four,five,six,seven,eight,nine};publicex11_2(){my=newTextField(20);res=newLabel(英文单词);setLayout(newFlowLayout());add(my);add(res);my.addActionListener(this);}publicvoidactionPerformed(ActionEvente){Strings=my.getText();intn=Integer.parseInt(s);res.setText(word[n]);}publicstaticvoidmain(Stringargs[]){Framemy=newex11_2();my.setSize(300,300);my.setVisible(true);}}