Java 8 StringSelection - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 StringSelection class.

This code example shows how to use the following methods:
		return ""; 
	} 
 
	public void setContents (String content) {
		java.awt.datatransfer.Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
		clipboard.setContents(new StringSelection(content), this);
	} 
 
	public void lostOwnership (java.awt.datatransfer.Clipboard clipboard, Transferable transferable) {
	} 
} 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
		return result;
	} 
 
	@Override 
	public void setContents (String content) {
		StringSelection stringSelection = new StringSelection(content);
		java.awt.datatransfer.Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
		clipboard.setContents(stringSelection, this);
	} 
 
	@Override 
	public void lostOwnership (java.awt.datatransfer.Clipboard arg0, Transferable arg1) {
	} 
} 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
        super(tr("Copy Link")); 
        this.vsr = vsr;
    } 
 
    public void actionPerformed(ActionEvent e) {
        StringSelection sel = new StringSelection(vsr.getMagnetLink());
        Toolkit.getDefaultToolkit().getSystemClipboard().setContents(sel, sel);
    } 
} 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
        this.queryPanel = queryPanel; 
    } 
 
    @Override 
    public void actionPerformed(AnActionEvent anActionEvent) { 
        CopyPasteManager.getInstance().setContents(new StringSelection(queryPanel.getQueryStringifiedValue())); 
    } 
} 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
        registerCustomShortcutSet(KeyEvent.VK_C, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), mongoResultPanel);
    } 
 
    @Override 
    public void actionPerformed(AnActionEvent anActionEvent) {
        CopyPasteManager.getInstance().setContents(new StringSelection(mongoResultPanel.getSelectedNodeStringifiedValue()));
    } 
} 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
 
  @Test
  public void canMakeUseOfTheClipboard() 
  { 
    assumeTrue(TestUtil.notHeadless()); 
    Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection("This Text"), model);
    String clipboard = model.getClipboardContents();
    assertEquals("This Text", clipboard);
  } 
 
  @Test
  public void canCopyPasteAndCut() 
  { 
    assumeTrue(TestUtil.notHeadless()); 
    model.setText("Some Text");
    model.setCaretLocation(TextLocation.origin);
    model.startSelection(TextLocation.at(0, 4));
    model.copySelection();
    String clipboard = model.getClipboardContents();
    assertEquals("Some", clipboard);
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
		String s = getScrollPane().getSelectedText();
 
		if (s == null) {
			s = getScrollPane().getText();
		} 
		ss = new StringSelection(s);
		Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, null);
	} 
 
	private JPanel getButtonsPanel() {
		if (buttonsPanel == null) {
			buttonsPanel = new JPanel();
			buttonsPanel.setPreferredSize(new Dimension(100, 30));
			buttonsPanel.setLayout(new GridBagLayout());
			buttonsPanel.setMinimumSize(new Dimension(20, 20));
			buttonsPanel.setMaximumSize(new Dimension(1000, 30));
 
			GridBagConstraints constraintsOKButton = new GridBagConstraints();
 
			constraintsOKButton.gridx = 1;
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
     * Sets a provided text to the system clipboard. 
     * 
     * @param text The text to set. 
     */ 
    public static void setText(String text) {
        Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(text), null);
    } 
 
    /** 
     * Gets a text from the system clipboard. 
     * 
     * @return A text if there is any or a null. 
     */ 
    public static String getText() {
        Transferable data = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
        try { 
            return (String)data.getTransferData(DataFlavor.stringFlavor);
        } 
        catch (Exception ignore) {
            return null; 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getTransferData, isDataFlavorSupported
 
        /* If it represents a String, use the StringSelection object's 
         * implementation to return the correct object. */ 
        else if ( mimeType.equals( stringFlavor.getMimeType() ) ) {
            Object obj = dataMap.get( flavor );
            Transferable stringTrans = new StringSelection( (String) obj );
            assert stringTrans.isDataFlavorSupported( stringFlavor );
            return stringTrans.getTransferData( stringFlavor );
        } 
 
        /* If it represents a DataSource, we need to supply it in an 
         * InputStream. */ 
        else if ( clazz.equals( InputStream.class ) ) {
            return new SourceInputStream( (DataSource) dataMap.get( flavor ) );
        } 
 
        /* We haven't put any other objects into our map. */ 
        else { 
            throw new UnsupportedFlavorException( flavor );
        } 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
        ); 
    }// </editor-fold>//GEN-END:initComponents 
 
    private void jCopyToClipboardButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCopyToClipboardButtonActionPerformed
        String text = jInfoTextArea.getText();
        Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(text), null);
    }//GEN-LAST:event_jCopyToClipboardButtonActionPerformed 
 
 
    // Variables declaration - do not modify//GEN-BEGIN:variables 
    private javax.swing.JButton jCopyToClipboardButton;
    private javax.swing.JLabel jHintCaption;
    private javax.swing.JTextArea jInfoTextArea;
    private javax.swing.JScrollPane jScrollPane1;
    // End of variables declaration//GEN-END:variables 
} 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
See Code Examples for Java 8 StringSelection Methods: