title: Cannot convert from void to String error
body: <p>I'm trying to make a simple program to encrypt and decrypt a message that a user enters. The problem is that in console everything works fine, but when I try to use JOptionPane I get an error stating that I cannot convert from void to string. The encrypt method works fine with JOptionPane. Its the decrypt method that has the problem. Below is my code:</p>
  
  <pre><code>import javax.swing.JOptionPane;
  
  public class Encrypt {
  
      public static final int ALPHASIZE = 26;
      public static final char[] alpha = { 'A', 'B', 'C', 'D', 'E', 'F', 'G',
              'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
              'U', 'V', 'W', 'X', 'Y', 'Z' };
  
      protected char[] encrypt = new char[ALPHASIZE];
      protected char[] decrypt = new char[ALPHASIZE];
  
      public Encrypt() {
          for (int i = 0; i &lt; ALPHASIZE; i++)
              encrypt[i] = alpha[(i + 3) % ALPHASIZE];
          for (int i = 0; i &lt; ALPHASIZE; i++)
              decrypt[encrypt[i] - 'A'] = alpha[i];
      }
  
      public String encryptMessage(String secret) {
          char[] mess = secret.toCharArray();
          for (int i = 0; i &lt; mess.length; i++)
              if (Character.isUpperCase(mess[i]))
                  mess[i] = encrypt[mess[i] - 'A'];
  
          return new String(mess);
  
      }
  
      public String decryptMessage(String secret) {
          char[] mess = secret.toCharArray();
          for (int i = 0; i &lt; mess.length; i++)
              if (Character.isUpperCase(mess[i]))
                  mess[i] = decrypt[mess[i] - 'A'];
  
          return new String(mess);
  
      }
  
      public static void main(String[] args) {
  
          Encrypt e = new Encrypt();
  
          // String secret = "THIS IS THE SECRET MESSAGE";
          // secret = e.encryptMessage(secret);
          // System.out.println("Encrypted: " + secret);
          // secret = e.decryptMessage(secret);
          // System.out.println("Decrypted: " + secret);
  
          String secret = JOptionPane.showInputDialog(null,"Enter message to be encrypted");
          JOptionPane.showMessageDialog(null, e.encryptMessage(secret));
  
          // this is where the problem is
          String userInput = JOptionPane.showInputDialog(null, "Do you want to convert the message? (Y/N)");
          if(userInput.equalsIgnoreCase("Y"))
              secret = JOptionPane.showMessageDialog(null, e.decryptMessage(secret)));
      }
  }
  </code></pre>