复制代码
- //:TextArea1.java
- //Usingthetextareacontrol
- importjava.awt.*;
- importjava.applet.*;
- publicclassTextArea1extendsApplet{
- Buttonb1=newButton("TextArea1");
- Buttonb2=newButton("TextArea2");
- Buttonb3=newButton("ReplaceText");
- Buttonb4=newButton("InsertText");
- TextAreat1=newTextArea("t1",1,30);
- TextAreat2=newTextArea("t2",4,30);
- publicvoidinit(){
- add(b1);
- add(t1);
- add(b2);
- add(t2);
- add(b3);
- add(b4);
- }
- publicbooleanaction(Eventevt,Objectarg){
- if(evt.target.equals(b1))
- getAppletContext().showStatus(t1.getText());
- elseif(evt.target.equals(b2)){
- t2.setText("InsertedbyButton2");
- t2.appendText(":"+t1.getText());
- getAppletContext().showStatus(t2.getText());
- }
- elseif(evt.target.equals(b3)){
- Strings="Replacement";
- t2.replaceText(s,3,3+s.length());
- }
- elseif(evt.target.equals(b4))
- t2.insertText("Inserted",10);
- //Letthebaseclasshandleit:
- else
- returnsuper.action(evt,arg);
- returntrue;//Wevehandledithere
- }
- }///:~
欢迎光临 仓酷云 (http://ckuyun.com/) | Powered by Discuz! X3.2 |