// applyRotAscii() -- Apply ASCII ROT PRivate void applyRotAscii(){ try{ int rotLength = Integer.parseInt(rotationLengthField.getText().trim()); // get rot len RotAscii cipher = new RotAscii(rotLength); // new cipher textArea.setText(cipher.transform(textArea.getText())); // transform }catch(Exception ex){ /* Show exception */ ExceptionDialog.show(this, "Invalid rotation length: ", ex); } }
Example 2. Good Comment Style
/** * Apply the ASCII rotation cipher to the user's text. The length is retrieved * from the rotation length field, and the user's text is retrieved from the * text area. * * @author Thornton Rose */ private void applyRotAscii() { int rotLength = 0; // rotation length RotAscii cipher = null; // ASCII rotation cipher
try { // Get rotation length field and convert to integer.