我正在尝试选择单选按钮选择程序使用哪种加密方法
@FXML
public void atbashChooser(ActionEvent event) {
}
@FXML
public void caesarChooser(ActionEvent evnt) {
}
@FXML
public void encryptShit(ActionEvent event) {
if (atbashButton.isSelected()){
encryptField.setText(new AtbashCipher().encrypt(messageField.getText()));
}
else if (caesarButton.isSelected()){
encryptField.setText(new CaesarCipher().encrypt(messageField.getText()));
}
}
@FXML
public void decryptShit(ActionEvent event) {
if (atbashButton.isSelected()){
decryptField.setText(new AtbashCipher().decrypt(messageField.getText()));
}
else if (caesarButton.isSelected()){
decryptField.setText(new CaesarCipher().decrypt(messageField.getText()));
}
}
这显然不起作用,但有没有办法以一种简单的方式做到这一点?如果有必要,我也可以共享FXML代码。