Package java.awt.datatransfer

Examples of java.awt.datatransfer.Clipboard


   */
  public void paste()
  {
    if(editable)
    {
      Clipboard clipboard = getToolkit().getSystemClipboard();
      try
      {
        // The MacOS MRJ doesn't convert \r to \n,
        // so do it here
        String selection = ((String)clipboard
          .getContents(this).getTransferData(
          DataFlavor.stringFlavor))
          .replace('\r','\n');

        int repeatCount = inputHandler.getRepeatCount();
View Full Code Here


      } catch (SecurityException se) {
        UIManager.getLookAndFeel().provideErrorFeedback(null);
        return;
      }
    }
    Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard();

    // Create the RTF selection.
    RtfGenerator gen = getRTFGenerator();
    Token tokenList = getTokenListFor(selStart, selEnd);
    for (Token t=tokenList; t!=null; t=t.getNextToken()) {
      if (t.isPaintable()) {
        if (t.textCount==1 && t.text[t.textOffset]=='\n') {
          gen.appendNewline();
        }
        else {
          Font font = getFontForTokenType(t.type);
          Color bg = getBackgroundForTokenType(t.type);
          boolean underline = getUnderlineForToken(t);
          // Small optimization - don't print fg color if this
          // is a whitespace color.  Saves on RTF size.
          if (t.isWhitespace()) {
            gen.appendToDocNoFG(t.getLexeme(), font, bg, underline);
          }
          else {
            Color fg = getForegroundForToken(t);
            gen.appendToDoc(t.getLexeme(), font, fg, bg, underline);
          }
        }
      }
    }

    // Set the system clipboard contents to the RTF selection.
    RtfTransferable contents = new RtfTransferable(gen.getRtf().getBytes());
    //System.out.println("*** " + new String(gen.getRtf().getBytes()));
    try {
      cb.setContents(contents, null);
    } catch (IllegalStateException ise) {
      UIManager.getLookAndFeel().provideErrorFeedback(null);
      return;
    }

View Full Code Here

            int selectedRow = tcTable.getSelectedRow();
            String message = (String)tcTable.getValueAt(selectedRow, DETAILS);
            if (message == null) {
                message = "";
            }
            Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
            StringSelection data = new StringSelection(message);
            clipboard.setContents(data, data);
        }
View Full Code Here

                        messages.append(eol);
                    }
                    messages.append(message);
                }
            }
            Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
            StringSelection data = new StringSelection(messages.toString());
            clipboard.setContents(data, data);
        }
View Full Code Here

     * Aus der Zwischenablage holen.
     *
     * @return  Der Text aus der Zwischenablage.
     */
    public String getClipbB() {
        Clipboard clip = Toolkit.getDefaultToolkit().getSystemClipboard();
        Transferable cont = clip.getContents(this);

        if (cont == null) {
             return null;
        } else {
            try {
View Full Code Here

    }

    public Boolean copyStringToClipboard(final String str) {

        final StringSelection stringSelection = new StringSelection(str);
        final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        clipboard.setContents(stringSelection, new ClipboardOwner() {

            public void lostOwnership(final Clipboard clipboard, final Transferable contents) {

            }
        });
View Full Code Here

     * Place a String on the clipboard, and make this class the owner of the Clipboard's contents.
     */
    public void setClipboardContents(final String aString) {

        final StringSelection stringSelection = new StringSelection(aString);
        final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        clipboard.setContents(stringSelection, this);
    }
View Full Code Here

     * @return any text found on the Clipboard; if none found, return an empty String.
     */
    public String getClipboardContents() {

        String result = "";
        final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        // odd: the Object param of getContents is not currently used
        final Transferable contents = clipboard.getContents(null);
        final boolean hasTransferableText = contents != null
                && contents.isDataFlavorSupported(DataFlavor.stringFlavor);
        if (hasTransferableText) {
            try {
                result = (String) contents.getTransferData(DataFlavor.stringFlavor);
View Full Code Here

     * Place a String on the clipboard, and make this class the owner of the Clipboard's contents.
     */
    public void setClipboardContents(final String aString) {

        final StringSelection stringSelection = new StringSelection(aString);
        final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        clipboard.setContents(stringSelection, this);
    }
View Full Code Here

     * @return any text found on the Clipboard; if none found, return an empty String.
     */
    public String getClipboardContents() {

        String result = "";
        final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        // odd: the Object param of getContents is not currently used
        final Transferable contents = clipboard.getContents(null);
        final boolean hasTransferableText = contents != null
                && contents.isDataFlavorSupported(DataFlavor.stringFlavor);
        if (hasTransferableText) {
            try {
                result = (String) contents.getTransferData(DataFlavor.stringFlavor);
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.