问答题
import java.awt.*;
import java.applet.*;
/*
<applet code="ex6_3.class" width=800 height=400 >
</applet>
*/
public class ex6_3 extends Applet{
private Button okBtn, clearBtn;
private String strMessage;
private TextArea tAreal, tArea2;
public void init(){
strMessage = "Hello! Welcome to the test! \n" +
"This is the NCR Examination! \n" +
"Wish you good luck!";
tAreal = new TextArea( 10, 25 );
tAreal.setText(strMessage);
tArea2 = new TextArea( 10, 25 );
tArea2.setEditable( true );
okBtn = new Button( "Copy" );
clearBtn = new Button( "Clear" );
add( tArea1 );
add( tArea2 );
add( okBtn );
add( clearBtn );
}
public boolean action( Event e, Object o ){
if( e.target == okBtn )
tAreal.setText(tArea2.getSelectedText() );
else if( e.target == clearBtn )
tAreal.setText( " " );
return true;
}
}
ex6_3. html
<HTML>
<HEAD>
<TITLE>ex6_3</TITLE>
</HEAD>
<BODY>
<applet code="ex6_3.class"width=800 height=400>
</applet>
</BODY>
</HTML>