title: JOptionPane char input
body: <p>I'm working on a hangman program in Java, and part of my code will be to obtain single letter guesses from the user through the JOptionPane dialog box (this is the input method my professor prefers as opposed to the scanner).</p>
  
  <p>I'm pretty new and have only gotten input from this dialog box as a string then converted the input to an int or double. I've been trying to find a way to get the input as a char but still use the dialog box. </p>
  
  <p>Anyone have a solution or know where I could look to find one?</p>
  
  <p>here's my code so far if you need it for reference.. the last line is where I got stuck</p>
  
  <pre><code>public static void main(String[] args) {
  
      String[] words = {
          "javascript", "declaration", "object", "program", "failing"
      };
  
      Random rnd = new Random();
  
      String rndWord = words[rnd.nextInt(words.length)];
  
      char[] displayArray = new char[rndWord.length()];
  
      for (int i = 0; i &lt; rndWord.length(); i++) {
          displayArray[i] = '_';
      }
  
      char[] alphabet = {
          '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'
      };
      String hangman = "Let's Play Hangman!!" + "\n" + "-------------" + "\n" + "|" + "\n" + "|" + "\n" + "|" + "\n" + "|" + "\n" + "|" + "\n" + "|" + "\n" + "|" + "\n" + "|" + "\n" + "\n" + Arrays.toString(displayArray) + "\n" + "       ";
  
      JOptionPane.showMessageDialog(null, hangman + " " + Arrays.toString(alphabet) + " ");
      String guess = JOptionPane.showInputDialog("Guess a letter: ");
  
  }
  </code></pre>