我在 swing 中开发了一个小程序,它将消息转换为加密形式。我对此一无所知,为什么这不起作用。
public class Encrypt extends javax.swing.JFrame {
String OriginalMsg,EncryptedMsg;
public Encrypt() {
initComponents();
OriginalMsg = jTextArea1.getText().toString();
EncryptedMsg = jTextArea2.getText().toString();
}
public void action(int a){
if(a == 0){
StringBuffer sb = new StringBuffer(OriginalMsg);
for(int i = 0; i < sb.length(); i++){
int temp = 0;
temp = (int)sb.charAt(i);
temp = temp * 11;
sb.setCharAt(i, (char)temp);
EncryptedMsg = sb.toString();
}
jTextArea2.setText(EncryptedMsg);
}
else if(a == 1){
jTextArea1.setText("");
jTextArea2.setText("");
}
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt){
action(0);
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt){
action(1);
}