title: Copying highlighted text in any place works correctly only first time
body: <p>By design, the buffer is placed in the <em>rawData</em> field. The selected text is placed in the buffer, after which it should be displayed in the notification area and then <em>rawData</em> place back to the buffer. In my case, copying correctly works only the first time. I'm using <a href="https://github.com/kristian/system-hook" rel="nofollow noreferrer">external library</a> for global keylistener. You can check all the code <a href="https://github.com/SweetSquid/translation" rel="nofollow noreferrer">here</a>. To start you need to select text and press Alt+X.</p>
  
  <pre><code>GlobalKeyboardHook keyboardHook = new GlobalKeyboardHook(true); // use false here to switch to hook instead of raw input
  
      keyboardHook.addKeyListener(new GlobalKeyAdapter() { //add key listener
          @Override public void keyPressed(GlobalKeyEvent event) {
              if (event.isMenuPressed() &amp;&amp; event.getVirtualKeyCode()!=0x58){ //0x58 equals X key  (Runs when alt+х pressed)
                  try {
                      rawData = (String) Toolkit.getDefaultToolkit().getSystemClipboard().getData(DataFlavor.stringFlavor); //get data raw data from clipboard
                      System.out.println("What was in clipboard:  " + rawData);
                      String kek = Copy.getCopy(); //get copied data
                      System.out.println("What was copied:  " + kek);
                      Notification.runNotification(kek); //start notification
                      Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(rawData), null); //returning raw data
                      System.out.println("What came into clipboard: " + Toolkit.getDefaultToolkit().getSystemClipboard().getData(DataFlavor.stringFlavor));
                  } catch (Exception e) {
                      throw  new RuntimeException(e);
                  }
              }
          }
  
  static String getCopy() throws IOException, UnsupportedFlavorException {
      robot.keyPress(KeyEvent.VK_CONTROL);
      robot.keyPress(KeyEvent.VK_C);
      robot.keyRelease(KeyEvent.VK_CONTROL);
      robot.keyRelease(KeyEvent.VK_C);
      return (String) Toolkit.getDefaultToolkit().getSystemClipboard().getData(DataFlavor.stringFlavor);
  }
  </code></pre>