Package java.awt.datatransfer

Examples of java.awt.datatransfer.Clipboard


        loadImage(image);
    }

    @Override
    protected void pasteFromClipboard() {
        final Clipboard cb = java.awt.Toolkit.getDefaultToolkit().getSystemClipboard();
        final Transferable content = cb.getContents(this);

        try {
            if (content.isDataFlavorSupported(DataFlavor.stringFlavor)) {
                // treat a string as a file
                final String filename = (String) content.getTransferData(DataFlavor.stringFlavor);
View Full Code Here


     *
     * job.end(); } frame.dispose();
     */

    public static void saveToClipboard(final String text) {
        final Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard();
        final StringSelection ss = new StringSelection(text);
        cb.setContents(ss, ss);
    }
View Full Code Here

        tree.getLastSelectedPathComponent();
    if (node == null) {
      return;
    }
    // is it better to use SwingUtilities2.canAccessSystemClipboard() here?
    Clipboard clipboard;
    try {
      clipboard = tree.getToolkit().getSystemClipboard();
    } catch (SecurityException e) {
      return;
    } catch (HeadlessException e) {
      return;
    }
    if (clipboard == null) {
      return;
    }
    StringBuilder text = new StringBuilder();
    treeLogTraverse(text, node, 0);
    StringSelection selection = new StringSelection(text.toString());
    clipboard.setContents(selection, selection);
  }
View Full Code Here

      for (int i=1; i<cbuff.length;++i) {
          cbuff[i] = iter.next();
      }
      label = new String(cbuff);
        }
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        StringSelection selection = new StringSelection(label);
        clipboard.setContents(selection, selection);
    }
      }
  }.start();
    }
View Full Code Here

   * Tests how an IllegalStateException from the ClipBoard is handled.
   */
  public void testIllegalStateException()
  {
    sourceActions = TransferHandler.COPY;
    clipboard = new Clipboard("DEFAULT")
    {
      public void setContents(Transferable t, ClipboardOwner o)
      {
        throw new IllegalStateException();
      }
View Full Code Here

        }
        buffer.append('\n');
      }
    }
    final StringSelection ss = new StringSelection(buffer.toString());
    final Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard();
    cb.setContents(ss, ss);

  }
View Full Code Here

      if(VisualEditor.clipboard == null) {
        try {
          VisualEditor.clipboard = this.getToolkit().getSystemClipboard();
        }
        catch(final Exception e) {
          VisualEditor.clipboard = new Clipboard("clipboard");
        }
      }
    }
  }
View Full Code Here

     * The paste method has been overloaded to strip off the <html><body> tags
     * This doesn't really work.
     */
    @Override
    public void paste() {
        Clipboard clipboard = getToolkit().getSystemClipboard();
        Transferable content = clipboard.getContents(this);
        if (content != null) {
            DataFlavor[] flavors = content.getTransferDataFlavors();
            try {
                for (int i = 0; i < flavors.length; i++) {
                    if (String.class.equals(flavors[i].getRepresentationClass())) {
View Full Code Here

    *
    * @since 1.0.13
    */
   public void doCopy()
   {
      Clipboard systemClipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
      Insets insets = getInsets();
      int w = getWidth() - insets.left - insets.right;
      int h = getHeight() - insets.top - insets.bottom;
      ChartTransferable selection = new ChartTransferable(this.chart, w, h,
              getMinimumDrawWidth(), getMinimumDrawHeight(),
              getMaximumDrawWidth(), getMaximumDrawHeight(), true);
      systemClipboard.setContents(selection, null);
   }
View Full Code Here

            }
            copyIn.append("\n");
        }
        StringSelection stsel = new StringSelection(copyIn.toString());
        Clipboard system = Toolkit.getDefaultToolkit().getSystemClipboard();

        system.setContents(stsel, stsel);
    }
View Full Code Here

TOP

Related Classes of java.awt.datatransfer.Clipboard

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.