code: public static void setText(String text){
          if(text==null)
              clear();
          else{
              StringSelection selection = new StringSelection(text);
              clipboard().setContents(selection, selection);
          }
      }
docs: replaces current contents of clipboard with the specified
  <code>text</code>. If <code>text</code> is null, this will
  clear the clipboard contents