Tabnine Logo
StringSelection.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
java.awt.datatransfer.StringSelection
constructor

Best Java code snippets using java.awt.datatransfer.StringSelection.<init> (Showing top 20 results out of 2,331)

Refine searchRefine arrow

  • Clipboard.setContents
  • Toolkit.getSystemClipboard
  • Toolkit.getDefaultToolkit
origin: libgdx/libgdx

@Override
public void setContents (String content) {
  try {
    StringSelection stringSelection = new StringSelection(content);
    java.awt.datatransfer.Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
    clipboard.setContents(stringSelection, this);
  } catch (Exception ignored) { // Ignore JDK crashes sorting data flavors.
  }
}
origin: stackoverflow.com

 String myString = "This text will be copied into clipboard when running this code!";
StringSelection stringSelection = new StringSelection(myString);
Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard();
clpbrd.setContents(stringSelection, null);
origin: nodebox/nodebox

  public void actionPerformed(ActionEvent actionEvent) {
    Clipboard clipboard = getToolkit().getSystemClipboard();
    StringSelection ss = new StringSelection(log);
    clipboard.setContents(ss, ExceptionDialog.this);
  }
});
origin: libgdx/libgdx

@Override
public void setContents (String content) {
  try {
    StringSelection stringSelection = new StringSelection(content);
    java.awt.datatransfer.Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
    clipboard.setContents(stringSelection, this);
  } catch (Exception ignored) { // Ignore JDK crashes sorting data flavors.
  }
}
origin: stackoverflow.com

 public static void type(String characters) {
  Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
  StringSelection stringSelection = new StringSelection( characters );
  clipboard.setContents(stringSelection, clipboardOwner);

  robot.keyPress(KeyEvent.VK_CONTROL);
  robot.keyPress(KeyEvent.VK_V);
  robot.keyRelease(KeyEvent.VK_V);
  robot.keyRelease(KeyEvent.VK_CONTROL);
}
origin: skylot/jadx

  public static void setClipboardString(String text) {
    try {
      Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
      Transferable transferable = new StringSelection(text);
      clipboard.setContents(transferable, null);
      LOG.debug("String '{}' copied to clipboard", text);
    } catch (Exception e) {
      LOG.error("Failed copy string '{}' to clipboard", text, e);
    }
  }
}
origin: RaiMan/SikuliX2

/**
 * Dumps a given text (either String or StringBuffer) into the Clipboard, with a default MIME type
 */
public static void putText(CharSequence data) {
 StringSelection copy = new StringSelection(data.toString());
 getSystemClipboard().setContents(copy, copy);
}
origin: MovingBlocks/Terasology

/**
 * Set the contents of the clipboard to a given value.
 *
 * @param str The new value of the clipboard contents
 */
protected void setClipboardContents(String str) {
  Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(str), null);
}
origin: stackoverflow.com

 String text = "Hello World";
StringSelection stringSelection = new StringSelection(text);
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(stringSelection, stringSelection);

Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_CONTROL);
origin: guoguibing/librec

public static void toClipboard(String data) throws Exception {
  Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard();
  StringSelection ss = new StringSelection(data);
  cb.setContents(ss, ss);
}
origin: bonnyfone/vectalign

public static void copyToClipboard(String data){
  Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard();
  clpbrd.setContents(new StringSelection(data), null);
}
origin: igniterealtime/Smack

  @Override
  public void actionPerformed(ActionEvent e) {
    // Get the clipboard
    Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
    // Set the sent text as the new content of the clipboard
    clipboard.setContents(new StringSelection(interpretedText1.getText()), null);
  }
});
origin: JetBrains/ideavim

 /**
  * Puts the supplied text into the system clipboard
  *
  * @param text The text to add to the clipboard
  */
 public static void setClipboardText(String text) {
  try {
   Clipboard board = Toolkit.getDefaultToolkit().getSystemClipboard();
   StringSelection data = new StringSelection(text);
   board.setContents(data, null);
  }
  catch (HeadlessException e) {
   // ignore
  }
 }
}
origin: igniterealtime/Smack

  @Override
  public void actionPerformed(ActionEvent e) {
    // Get the clipboard
    Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
    // Set the sent text as the new content of the clipboard
    clipboard.setContents(new StringSelection(messageTextArea.getText()), null);
  }
});
origin: igniterealtime/Smack

  @Override
  public void actionPerformed(ActionEvent e) {
    // Get the clipboard
    Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
    // Set the sent text as the new content of the clipboard
    clipboard.setContents(new StringSelection(receivedText.getText()), null);
  }
});
origin: igniterealtime/Smack

  @Override
  public void actionPerformed(ActionEvent e) {
    // Get the clipboard
    Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
    // Set the sent text as the new content of the clipboard
    clipboard.setContents(new StringSelection(sentText1.getText()), null);
  }
});
origin: igniterealtime/Smack

  @Override
  public void actionPerformed(ActionEvent e) {
    // Get the clipboard
    Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
    // Set the sent text as the new content of the clipboard
    clipboard.setContents(new StringSelection(receivedText1.getText()), null);
  }
});
origin: igniterealtime/Smack

  @Override
  public void actionPerformed(ActionEvent e) {
    // Get the clipboard
    Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
    // Set the sent text as the new content of the clipboard
    clipboard.setContents(new StringSelection(sentText.getText()), null);
  }
});
origin: wiztools/rest-client

public static void clipboardCopy(String str) {
  Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
  clipboard.setContents(new StringSelection(str), null);
}

origin: MovingBlocks/Terasology

  @Override
  public boolean setClipboardContents(String value) {
    return AccessController.doPrivileged(
        (PrivilegedAction<Boolean>) () -> {
          Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
          try {
            clipboard.setContents(new StringSelection(value), null);
          } catch (IllegalStateException exp) {
            // Some OSs might lock out access to clipboard, if another application uses it.
            // In this case, this exception is thrown
            return false;
          }
          return true;
        });
  }
}
java.awt.datatransferStringSelection<init>

Popular methods of StringSelection

  • getTransferDataFlavors
  • getTransferData
  • isDataFlavorSupported

Popular in Java

  • Parsing JSON documents to java classes using gson
  • addToBackStack (FragmentTransaction)
  • findViewById (Activity)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • Point (java.awt)
    A point representing a location in (x,y) coordinate space, specified in integer precision.
  • URLConnection (java.net)
    A connection to a URL for reading or writing. For HTTP connections, see HttpURLConnection for docume
  • Permission (java.security)
    Legacy security code; do not use.
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • JFileChooser (javax.swing)
  • JList (javax.swing)
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now