62,623
社区成员
发帖
与我相关
我的任务
分享
public class TextAreaDemo extends Applet {
String msg;
public void init(){
setBackground(Color.cyan );
setForeground(Color.blue);
String str = "I am ChengHuaFang,\n" +
"a student of centre south university.\n" +
"Now I am tweenty-one.\n";
TextArea text = new TextArea(str,10,33);
add(text);
addMouseListener(new MyMouseAdapter(this));
}
class MyMouseAdapter extends MouseAdapter{
TextAreaDemo adapterDemo;
public MyMouseAdapter(TextAreaDemo adapterDemo){
this.adapterDemo = adapterDemo;
}
public void mouseClicked(MouseEvent me){
adapterDemo.showStatus("mouse clicked") ;
}
}
public void paint(Graphics g ){
msg = "now is other";
g.drawString(msg,24,190);
}
}