Fix NPE when getting text from clipboard.

The clipboard may return null if the clipboard contains something other
than text. This is documented in the API but that case was not
considered by the code.