中华地标产业发展联盟:java的问题

来源:百度文库 编辑:查人人中国名人网 时间:2024/04/29 13:49:56
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
class MyButton extends Button implements ActionListener,TextListener
{TextArea text1,text2;
char save[];
MyButton(String s,Container con)
{super(s);
text1=new TextArea(6,12);
text2=new TextArea(6,12);
text2.setEditable(false);
text1.addTextListener(this);
this.addActionListener(this);
con.add(text1);
con.add(text2);
con.add(this);
}
public void textValueChanged(TextEvent e)
{String s=text1.getText();
StringBuffer strbuffer=new StringBuffer(s);//这里是什么意思?
String temp=new String(strbuffer.reverse());//这里是什么意思?
text2.setText(temp);
}
public void actionPerformed(ActionEvent e)
{text2.setText(null);
String s=text1.getText();
int length=s.length();
save=new char[length];
s.getChars(0,length,save,0);
for(int i=0;i<save.length;i++)
{save[i]=(char)(save[i]^'你');
}
String temp=new String(save);
text2.setText(temp);
}
}
public class e102 extends Applet implements ActionListener
{MyButton mybutton;
Button button;
public void init()
{mybutton=new MyButton("加密",this);
button=new Button("解密");
button.addActionListener(this);
add(button);
}
public void actionPerformed(ActionEvent e)
{for(int i=0;i<mybutton.save.length;i++)
{mybutton.save[i]=(char)(mybutton.save[i]^'你');
}
String temp=new String(mybutton.save);
mybutton.text2.setText(temp);
}
}
//能解释这个程序吗?还有为什么能在按扭类中加入文本区
??
问题见注释,谢谢!!

StringBuffer strbuffer=new StringBuffer(s);//是将text1处获取的文本转化为StringBuffer对像

我晕 这么长 兄弟 这里说不清楚 加我QQ40567487 我给你解释 加的时候说明清楚啊 要不我是决绝加好友的