Lire le contenu HTML du presse-papier

Author:


{filelink=846}
Ce programme lit le contenu du presse-papier édite via la classe ‘TransferHandler’

 private String paste()
    {
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        String text="";

           try
           {        DataFlavor[] supportedFlavors= new DataFlavor[]{
                    new DataFlavor("text/html;class=java.lang.String"),
                    new DataFlavor("text/plain;class=java.lang.String")};
                    DataFlavor flavor = DataFlavor.selectBestTextFlavor(supportedFlavors);
              if (clipboard.isDataFlavorAvailable(flavor))
              {  
              text = (String) clipboard.getData(flavor);
             // txtPaste.setText(text);
               }
              

           }
           catch (Exception e)
           {
              JOptionPane.showMessageDialog(this, e);
           }

    
        return text;
     }

Leave a Reply

Your email address will not be published. Required fields are marked *