title: How to cut/copy text in JPasswordField as char array?
body: <p>How to cut/copy the password in the <code>JPasswordField</code> into the clipboard by using the <strong>non-String API</strong>. Thereby closing a window for the hacker to see the password.</p>
  
  <p>According to this link <a href="https://stackoverflow.com/a/8885343/2534090">https://stackoverflow.com/a/8885343/2534090</a> the char array is different from the text.</p>
  
  <pre><code>public static void main(String[] args) {
      Object pw = "Password";
      System.out.println("String: " + pw);
  
      pw = "Password".toCharArray();
      System.out.println("Array: " + pw);
  }
  </code></pre>
  
  <p><strong>Prints:</strong></p>
  
  <pre><code>String: Password
  Array: [C@5829428e
  </code></pre>
  
  <p>What i want to be in the clipboard is <code>[C@5829428e</code> but not <code>Password</code></p>
  
  <p>I tried using <code>StringSelection</code> to copy the contents in the clipboard but it's constructor takes a <code>String</code> which is immutable and not safe.</p>